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

@ -359,6 +359,12 @@ func TestVarzHandler(t *testing.T) {
new(expvar.Int),
"# TYPE foo counter\nfoo 0\n",
},
{
"dash_in_metric_name",
"counter_foo-bar",
new(expvar.Int),
"# TYPE foo_bar counter\nfoo_bar 0\n",
},
{
"int_with_type_counter",
"counter_foo",