mirror of
https://github.com/tailscale/tailscale.git
synced 2026-10-08 11:21:51 -04:00
The varz handler got its memstats_* metrics from the expvar package's "memstats" func, which calls runtime.ReadMemStats and so stopped the world on every Prometheus scrape. Keep the names but compute them from runtime/metrics, and never call that func, even from WritePrometheusExpvar. While there, export the /tailscale/ metrics from our Go fork (stack size histogram, stack copy counters, timer zombie counts and lifetime histogram), which nothing could see before, plus a few upstream ones with no MemStats equivalent: scheduling latency and GC pause histograms, live heap, GC and total CPU seconds, thread count, and mutex wait time. The last replaces derper's hand-rolled version. Everything read is cheap and a scrape allocates nothing after the first. Names use a go_runtime_ namespace rather than go_ so they can't collide with the Prometheus Go client's collector in promvarz binaries. The runtime's 162-bucket time histograms are reduced to one bucket per factor of four from 256ns to 1s. Updates #21300 Updates tailscale/go#189 Updates golang/go#75935 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Change-Id: I7e3c9a41f2b85d6e0c4a9b1d3f8e7c2a5b6d4e19