mirror of
https://github.com/ferdzo/fs.git
synced 2026-04-05 01:36:25 +00:00
Minimal fixes for metrics
This commit is contained in:
@@ -762,7 +762,7 @@ func trimFloat(v float64) string {
|
||||
}
|
||||
|
||||
func escapeLabelValue(value string) string {
|
||||
value = strings.ReplaceAll(value, `\\`, `\\\\`)
|
||||
value = strings.ReplaceAll(value, `\`, `\\`)
|
||||
value = strings.ReplaceAll(value, "\n", `\\n`)
|
||||
value = strings.ReplaceAll(value, `"`, `\\"`)
|
||||
return value
|
||||
|
||||
@@ -24,3 +24,11 @@ func TestRenderPrometheusHistogramNoEmptyLabelSet(t *testing.T) {
|
||||
t.Fatalf("unexpected empty label set for gc count metric")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEscapeLabelValueEscapesSingleBackslash(t *testing.T) {
|
||||
got := escapeLabelValue(`a\b`)
|
||||
want := `a\\b`
|
||||
if got != want {
|
||||
t.Fatalf("escapeLabelValue returned %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user