From 2c02f712d1961b1260fcdf488d7971d7c833fabe Mon Sep 17 00:00:00 2001 From: Nick Khyl Date: Fri, 31 Jan 2025 16:09:15 -0600 Subject: [PATCH] util/syspolicy/internal/metrics: replace dots with underscores for metric names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dots are not allowed in metric names and cause panics. Since we use dots in names like AlwaysOn.OverrideWithReason, let's replace them with underscores. We don’t want to use setting.KeyPathSeparator here just yet to make it fully hierarchical, but we will decide as we progress on the (experimental) AlwaysOn.* policy settings. tailscale/corp#26146 Signed-off-by: Nick Khyl --- util/syspolicy/internal/metrics/metrics.go | 1 + 1 file changed, 1 insertion(+) diff --git a/util/syspolicy/internal/metrics/metrics.go b/util/syspolicy/internal/metrics/metrics.go index d8ba271a8..770a34d29 100644 --- a/util/syspolicy/internal/metrics/metrics.go +++ b/util/syspolicy/internal/metrics/metrics.go @@ -285,6 +285,7 @@ func SetHooksForTest(tb internal.TB, addMetric, setMetric metricFn) { func newSettingMetric(key setting.Key, scope setting.Scope, suffix string, typ clientmetric.Type) metric { name := strings.ReplaceAll(string(key), string(setting.KeyPathSeparator), "_") + name = strings.ReplaceAll(name, ".", "_") // dots are not allowed in metric names return newMetric([]string{name, metricScopeName(scope), suffix}, typ) }