tsweb: avoid dashes in Prometheus metric names

Ideally we should strip other invalid characters too, but that would
call for a regexp replacement which increases the number of allocations
and makes `TestVarzHandlerSorting` fail.

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
This commit is contained in:
Anton Tolchanov
2022-11-17 09:34:32 -08:00
committed by Anton Tolchanov
parent dd50dcd067
commit 3c27632ffe
2 changed files with 7 additions and 1 deletions

View File

@@ -474,7 +474,7 @@ func writePromExpVar(w io.Writer, prefix string, kv expvar.KeyValue) {
label, key = a, b
}
}
name := prefix + key
name := strings.ReplaceAll(prefix+key, "-", "_")
switch v := kv.Value.(type) {
case PrometheusVar: