cmd/checkmetrics: add command for checking metrics against kb

This commit adds a command to validate that all the metrics that
are registring in the client are also present in a path or url.

It is intended to be ran from the KB against the latest version of
tailscale.

Updates tailscale/corp#24066
Updates tailscale/corp#22075

Co-Authored-By: Brad Fitzpatrick <bradfitz@tailscale.com>
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2024-10-22 13:53:34 -05:00
committed by Kristoffer Dalby
parent 13faa64c14
commit a68efe2088
2 changed files with 142 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ import (
"tailscale.com/metrics"
"tailscale.com/tsweb/varz"
"tailscale.com/util/set"
)
// Registry tracks user-facing metrics of various Tailscale subsystems.
@@ -106,3 +107,13 @@ func (r *Registry) String() string {
return sb.String()
}
// Metrics returns the name of all the metrics in the registry.
func (r *Registry) MetricNames() []string {
ret := make(set.Set[string])
r.vars.Do(func(kv expvar.KeyValue) {
ret.Add(kv.Key)
})
return ret.Slice()
}