Skip to content

Commit

Permalink
fixed bug when raft peer is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamna committed May 11, 2024
1 parent c4f4810 commit 4343ac4
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions surveyor/jetstream_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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,
Expand Down Expand Up @@ -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{
Expand All @@ -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,
Expand Down

0 comments on commit 4343ac4

Please sign in to comment.