feat(telemetry/state_view): add site_id label to gauges and set tunnel_sessions transport=wireguard (no hardcoded tcp)

This commit is contained in:
Marc Schäfer
2025-10-08 00:09:30 +02:00
parent 1e88fb86b4
commit 83c3ae5cf9

View File

@@ -42,18 +42,23 @@ func RegisterStateView(v StateView) {
if online { if online {
val = 1 val = 1
} }
o.ObserveInt64(mSiteOnline, val) o.ObserveInt64(mSiteOnline, val, metric.WithAttributes(
attribute.String("site_id", getSiteID()),
))
} }
if t, ok := sv.LastHeartbeat(siteID); ok { if t, ok := sv.LastHeartbeat(siteID); ok {
secs := time.Since(t).Seconds() secs := time.Since(t).Seconds()
o.ObserveFloat64(mSiteLastHeartbeat, secs) o.ObserveFloat64(mSiteLastHeartbeat, secs, metric.WithAttributes(
attribute.String("site_id", getSiteID()),
))
} }
// If the view supports per-tunnel sessions, report them labeled by tunnel_id. // If the view supports per-tunnel sessions, report them labeled by tunnel_id.
if tm, ok := any.(interface{ SessionsByTunnel() map[string]int64 }); ok { if tm, ok := any.(interface{ SessionsByTunnel() map[string]int64 }); ok {
for tid, n := range tm.SessionsByTunnel() { for tid, n := range tm.SessionsByTunnel() {
o.ObserveInt64(mTunnelSessions, n, metric.WithAttributes( o.ObserveInt64(mTunnelSessions, n, metric.WithAttributes(
attribute.String("site_id", getSiteID()),
attribute.String("tunnel_id", tid), attribute.String("tunnel_id", tid),
attribute.String("transport", "tcp"), attribute.String("transport", "wireguard"),
)) ))
} }
} }