metrics: add histogram support

Add initial histogram support.

Updates tailscale/corp#8641

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2023-05-08 01:22:23 -07:00
committed by Maisem Ali
parent 9101fabdf8
commit 3304819739
2 changed files with 99 additions and 1 deletions

View File

@@ -191,6 +191,8 @@ func writePromExpVar(w io.Writer, prefix string, kv expvar.KeyValue) {
v.Do(func(kv expvar.KeyValue) {
fmt.Fprintf(w, "%s{%s=%q} %v\n", name, cmpx.Or(v.Label, "label"), kv.Key, kv.Value)
})
case *metrics.Histogram:
v.PromExport(w, name)
case *expvar.Map:
if label != "" && typ != "" {
fmt.Fprintf(w, "# TYPE %s %s\n", name, typ)