prober: clone histogram buckets before handing to Prometheus for derp_qd_probe_delays_seconds

Updates tailscale/corp#25697

Signed-off-by: Percy Wegmann <percy@tailscale.com>
This commit is contained in:
Percy Wegmann 2025-01-08 11:44:10 -06:00 committed by Percy Wegmann
parent 8d4ca13cf8
commit c81a95dd53

View File

@ -15,6 +15,7 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"maps"
"net" "net"
"net/http" "net/http"
"net/netip" "net/netip"
@ -350,7 +351,7 @@ func (d *derpProber) probeQueuingDelay(from, to string, packetsPerSecond int, pa
qdh.mx.Lock() qdh.mx.Lock()
result := []prometheus.Metric{ result := []prometheus.Metric{
prometheus.MustNewConstMetric(prometheus.NewDesc("derp_qd_probe_dropped_packets", "Total packets dropped", nil, l), prometheus.CounterValue, float64(packetsDropped.Value())), prometheus.MustNewConstMetric(prometheus.NewDesc("derp_qd_probe_dropped_packets", "Total packets dropped", nil, l), prometheus.CounterValue, float64(packetsDropped.Value())),
prometheus.MustNewConstHistogram(prometheus.NewDesc("derp_qd_probe_delays_seconds", "Distribution of queuing delays", nil, l), qdh.count, qdh.sum, qdh.bucketedCounts), prometheus.MustNewConstHistogram(prometheus.NewDesc("derp_qd_probe_delays_seconds", "Distribution of queuing delays", nil, l), qdh.count, qdh.sum, maps.Clone(qdh.bucketedCounts)),
} }
qdh.mx.Unlock() qdh.mx.Unlock()
return result return result