From 4aff1790648957fb9d4f58329b24f9ca8e83da51 Mon Sep 17 00:00:00 2001 From: Anton Tolchanov Date: Mon, 26 Feb 2024 15:38:31 +0000 Subject: [PATCH] ipn/{ipnlocal,localapi}: export varz via v2n, peerapi and localapi Updates #cleanup Signed-off-by: Anton Tolchanov --- cmd/tailscaled/tailscaled.go | 6 ++---- ipn/ipnlocal/c2n.go | 2 ++ ipn/ipnlocal/peerapi.go | 2 ++ ipn/localapi/localapi.go | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/tailscaled/tailscaled.go b/cmd/tailscaled/tailscaled.go index a2ab7271c..4076c591f 100644 --- a/cmd/tailscaled/tailscaled.go +++ b/cmd/tailscaled/tailscaled.go @@ -791,10 +791,8 @@ func newNetstack(logf logger.Logf, sys *tsd.System) (*netstack.Impl, error) { if err != nil { return nil, err } - // Only register debug info if we have a debug mux - if debugMux != nil { - expvar.Publish("netstack", ret.ExpVar()) - } + // These are exposed via the local debug server, c2n, peerapi and localapi. + expvar.Publish("netstack", ret.ExpVar()) return ret, nil } diff --git a/ipn/ipnlocal/c2n.go b/ipn/ipnlocal/c2n.go index de6ca2321..1df98e80d 100644 --- a/ipn/ipnlocal/c2n.go +++ b/ipn/ipnlocal/c2n.go @@ -29,6 +29,7 @@ import ( "tailscale.com/net/sockstats" "tailscale.com/posture" "tailscale.com/tailcfg" + "tailscale.com/tsweb/varz" "tailscale.com/util/clientmetric" "tailscale.com/util/goroutines" "tailscale.com/util/set" @@ -151,6 +152,7 @@ func handleC2NDebugPrefs(b *LocalBackend, w http.ResponseWriter, r *http.Request func handleC2NDebugMetrics(_ *LocalBackend, w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") + varz.Handler(w, r) clientmetric.WritePrometheusExpositionFormat(w) } diff --git a/ipn/ipnlocal/peerapi.go b/ipn/ipnlocal/peerapi.go index aa18c3588..a967b4d5b 100644 --- a/ipn/ipnlocal/peerapi.go +++ b/ipn/ipnlocal/peerapi.go @@ -40,6 +40,7 @@ import ( "tailscale.com/net/sockstats" "tailscale.com/tailcfg" "tailscale.com/taildrop" + "tailscale.com/tsweb/varz" "tailscale.com/types/views" "tailscale.com/util/clientmetric" "tailscale.com/util/httphdr" @@ -799,6 +800,7 @@ func (h *peerAPIHandler) handleServeMetrics(w http.ResponseWriter, r *http.Reque return } w.Header().Set("Content-Type", "text/plain") + varz.Handler(w, r) clientmetric.WritePrometheusExpositionFormat(w) } diff --git a/ipn/localapi/localapi.go b/ipn/localapi/localapi.go index 565bb7b4e..01905474d 100644 --- a/ipn/localapi/localapi.go +++ b/ipn/localapi/localapi.go @@ -50,6 +50,7 @@ import ( "tailscale.com/taildrop" "tailscale.com/tka" "tailscale.com/tstime" + "tailscale.com/tsweb/varz" "tailscale.com/types/key" "tailscale.com/types/logger" "tailscale.com/types/logid" @@ -568,6 +569,7 @@ func (h *Handler) serveMetrics(w http.ResponseWriter, r *http.Request) { return } w.Header().Set("Content-Type", "text/plain") + varz.Handler(w, r) clientmetric.WritePrometheusExpositionFormat(w) }