From 4343ac4c21362b4c5b9a775714219b494ff90584 Mon Sep 17 00:00:00 2001 From: Sina Date: Sat, 11 May 2024 23:41:55 +0330 Subject: [PATCH] fixed bug when raft peer is changed --- surveyor/jetstream_configs.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/surveyor/jetstream_configs.go b/surveyor/jetstream_configs.go index c1c961a..f17fe4a 100644 --- a/surveyor/jetstream_configs.go +++ b/surveyor/jetstream_configs.go @@ -213,6 +213,11 @@ func (o *jsConfigListListener) StreamHandler(streamInfo *nats.StreamInfo) { o.metrics.jsStreamRaftPeerInfo.DeletePartialMatch(prometheus.Labels{ "stream_name": streamInfo.Config.Name, }) + o.metrics.jsStreamReplicationLag.DeletePartialMatch( + prometheus.Labels{ + "stream_name": streamInfo.Config.Name, + }, + ) for _, peer := range streamInfo.Cluster.Replicas { o.metrics.jsStreamRaftPeerInfo.With( prometheus.Labels{ @@ -224,11 +229,7 @@ func (o *jsConfigListListener) StreamHandler(streamInfo *nats.StreamInfo) { "lag": strconv.FormatUint(peer.Lag, 10), }, ).Set(1) - o.metrics.jsStreamReplicationLag.DeletePartialMatch( - prometheus.Labels{ - "stream_name": streamInfo.Config.Name, - }, - ) + o.metrics.jsStreamReplicationLag.With( prometheus.Labels{ "stream_name": streamInfo.Config.Name, @@ -294,6 +295,12 @@ func (o *jsConfigListListener) ConsumerHandler(consumerInfo *nats.ConsumerInfo) "stream_name": consumerInfo.Stream, "consumer_name": consumerInfo.Name, }) + o.metrics.jsConsumerReplicationLag.DeletePartialMatch( + prometheus.Labels{ + "stream_name": consumerInfo.Stream, + "consumer_name": consumerInfo.Name, + }, + ) for _, peer := range consumerInfo.Cluster.Replicas { o.metrics.jsConsumerRaftPeerInfo.With( prometheus.Labels{ @@ -306,12 +313,7 @@ func (o *jsConfigListListener) ConsumerHandler(consumerInfo *nats.ConsumerInfo) "lag": strconv.FormatUint(peer.Lag, 10), }, ).Set(1) - o.metrics.jsConsumerReplicationLag.DeletePartialMatch( - prometheus.Labels{ - "stream_name": consumerInfo.Stream, - "consumer_name": consumerInfo.Name, - }, - ) + o.metrics.jsConsumerReplicationLag.With( prometheus.Labels{ "stream_name": consumerInfo.Stream,