author | Alberto Bertogli
<albertito@blitiri.com.ar> 2021-01-16 13:08:46 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2021-01-16 13:08:46 UTC |
parent | 887a1cef686a2d7fcce81dbc379e18969b3c09f8 |
internal/expvarom/expvarom.go | +6 | -0 |
internal/expvarom/expvarom_test.go | +1 | -0 |
diff --git a/internal/expvarom/expvarom.go b/internal/expvarom/expvarom.go index 1d02fd7..d9d00a4 100644 --- a/internal/expvarom/expvarom.go +++ b/internal/expvarom/expvarom.go @@ -13,6 +13,7 @@ // // The exporter uses the text-based format, as documented in: // https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format +// https://github.com/OpenObservability/OpenMetrics/blob/master/specification/OpenMetrics.md // // Note the adoption of that format as OpenMetrics' one isn't finalized yet, // and it is possible that it will change in the future. @@ -54,6 +55,10 @@ var ( func MetricsHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain; version=0.0.4") + // Update to this once it's standard and Prometheus and other ingesters + // can handle this. + //w.Header().Set("Content-Type", "application/openmetrics-text; version=1.0.0; charset=utf-8") + vars := []exportedVar{} ignored := []string{} expvar.Do(func(kv expvar.KeyValue) { @@ -99,6 +104,7 @@ func MetricsHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "# Generated by expvarom\n") fmt.Fprintf(w, "# EXPERIMENTAL - Format is not fully standard yet\n") fmt.Fprintf(w, "# Ignored variables: %q\n", ignored) + fmt.Fprintf(w, "# EOF\n") // Mandated by the standard. } func writeVar(w io.Writer, v *exportedVar) { diff --git a/internal/expvarom/expvarom_test.go b/internal/expvarom/expvarom_test.go index 4ce3c1e..511ce97 100644 --- a/internal/expvarom/expvarom_test.go +++ b/internal/expvarom/expvarom_test.go @@ -73,6 +73,7 @@ testMXI{key="key3"} 7 # Generated by expvarom # EXPERIMENTAL - Format is not fully standard yet # Ignored variables: ["cmdline" "memstats" "testS"] +# EOF ` func TestHandler(t *testing.T) {