diff --git a/internal/expvarom/expvarom.go b/internal/expvarom/expvarom.go index 12f9ce2..6197cc7 100644 --- a/internal/expvarom/expvarom.go +++ b/internal/expvarom/expvarom.go @@ -98,9 +98,8 @@ func MetricsHandler(w http.ResponseWriter, r *http.Request) { writeVar(w, &v) } - 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, "# HELP generated_by expvarom\n") + fmt.Fprintf(w, "# HELP ignored_variables %q\n", ignored) fmt.Fprintf(w, "# EOF\n") // Mandated by the standard. } @@ -110,12 +109,12 @@ func writeVar(w io.Writer, v *exportedVar) { } if v.I != nil { - fmt.Fprintf(w, "%s %d\n\n", v.Name, v.I.Value()) + fmt.Fprintf(w, "%s %d\n", v.Name, v.I.Value()) return } if v.F != nil { - fmt.Fprintf(w, "%s %g\n\n", v.Name, v.F.Value()) + fmt.Fprintf(w, "%s %g\n", v.Name, v.F.Value()) return } @@ -139,9 +138,6 @@ func writeVar(w io.Writer, v *exportedVar) { v.Name, v.LabelName, labelValue, vs) count++ }) - if count > 0 { - fmt.Fprintf(w, "\n") - } } } diff --git a/internal/expvarom/expvarom_test.go b/internal/expvarom/expvarom_test.go index b375ed9..b4be539 100644 --- a/internal/expvarom/expvarom_test.go +++ b/internal/expvarom/expvarom_test.go @@ -36,24 +36,16 @@ var ( ) const expected string = `_ame_5 5 - i3name 3 - nAme_4Z 4 - name_1z 1 - # HELP name_2 name with $ name_2 2 - # HELP testF float test var testF 3.43434 - # HELP testI1 int test var testI1 1 - testI2 2 - # HELP testMF float map test var testMF{label="key2.0"} 6.6 testMF{label="key2.1"} 6.61 @@ -63,17 +55,12 @@ testMF{label="key2.4- "} 6.64 testMF{label="key2.5-a\nb"} 6.65 testMF{label="key2.6-a\"b"} 6.66 testMF{label="key2.7-\\u00f1aca-A\\t\\xff\\xfe\\xfdB"} 6.67 - # HELP testMI int map test var testMI{label="key1"} 5 - testMXF{key="key4"} 8e-08 - testMXI{key="key3"} 7 - -# Generated by expvarom -# EXPERIMENTAL - Format is not fully standard yet -# Ignored variables: ["cmdline" "memstats" "testS"] +# HELP generated_by expvarom +# HELP ignored_variables ["cmdline" "memstats" "testS"] # EOF `