Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix varz_jetstream_meta_leader reports more than one leader #180

Merged

Conversation

VictorPerezForm3
Copy link
Contributor

Fix #179

collector/collector.go Outdated Show resolved Hide resolved
@@ -231,6 +231,7 @@ func (nc *NATSCollector) collectStatsFromRequests(
case float64: // json only has floats
m.WithLabelValues(id).Set(v)
case string:
m.Reset()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@VictorPerezForm3
Copy link
Contributor Author

After thinking about this issue, I believe the same thing will happen with float values because they contain dynamic labels such as "meta_leader". For example, for the metric nats_stream_last_seq In case of a meta leader relection, the value will freeze and a new metric will be created.

I didn't attempt to reproduce it, but if you can reproduce, maybe it should just reset all gauges before setting the new values. This way old labels will be clean up.

The problem is that this approach won't work for counters. Maybe you should think about removing dynamic labels from metrics. You can create a single gauge to hold all the values and then merge with other metrics if you need to extend the information.

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@variadico variadico changed the title Fix #179 Fix varz_jetstream_meta_leader reports more than one leader Jun 1, 2022
@variadico variadico merged commit a5dc5f1 into nats-io:main Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

varz_jetstream_meta_leader reports more than one leader
3 participants