From c84727592242195c9edaa623f51792d31cf50129 Mon Sep 17 00:00:00 2001 From: Samuel Attwood <45669855+samuelattwood@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:33:05 -0400 Subject: [PATCH] Avoid Nil Pointer with JetstreamAPIPending (#220) * Avoid potential nil pointer with JetstreamAPIPending metric * Counter -> Gauge --- surveyor/collector_statz.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surveyor/collector_statz.go b/surveyor/collector_statz.go index ef5871c..5d4869b 100644 --- a/surveyor/collector_statz.go +++ b/surveyor/collector_statz.go @@ -987,7 +987,6 @@ func (sc *StatzCollector) Collect(ch chan<- prometheus.Metric) { metrics.newGaugeMetric(sc.descs.JetstreamHAAssets, float64(sm.Stats.JetStream.Stats.HAAssets), lblServerID) // At present, Total does not include Errors. Keeping them separate metrics.newCounterMetric(sc.descs.JetstreamAPIRequests, float64(sm.Stats.JetStream.Stats.API.Total), lblServerID) - metrics.newCounterMetric(sc.descs.JetstreamAPIPending, float64(sm.Stats.JetStream.Meta.Pending), lblServerID) metrics.newCounterMetric(sc.descs.JetstreamAPIErrors, float64(sm.Stats.JetStream.Stats.API.Errors), lblServerID) } @@ -1000,6 +999,7 @@ func (sc *StatzCollector) Collect(ch chan<- prometheus.Metric) { jsRaftGroupLabelValues := []string{sm.Server.ID, serverName(&sm.Server), sm.Server.Cluster} // FIXME: add labels needed or remove... + metrics.newGaugeMetric(sc.descs.JetstreamAPIPending, float64(sm.Stats.JetStream.Meta.Pending), jsRaftGroupLabelValues) metrics.newGaugeMetric(sc.descs.JetstreamClusterRaftGroupSize, float64(sm.Stats.JetStream.Meta.Size), jsRaftGroupLabelValues) // Could provide false positive if two server have the same server_name in the same or different clusters in the super-cluster...