-
Notifications
You must be signed in to change notification settings - Fork 379
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: avoid mutation bug in registry #273
Conversation
The defaultLabels feature is buggy when used in combination with the `.labels()` sub counter feature. We mutate the object in the serialization implementation which means the next time you observe the value the labels object has been incorrectly mutated. The functionality of `.labels()` is supposed to be the caching of the labels object itself instead of constantly re-using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test and update the changelog as well, please?
Code itself LGTM 🙂
I've updated changelog and added a test that fails without my patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Awesome. |
Bug introduced at siimon#220 and fixed for .getMetricAsPrometheusString() at siimon#273
Bug introduced at siimon#220 and fixed for .getMetricAsPrometheusString() at siimon#273
The defaultLabels feature is buggy when used in combination
with the
.labels()
sub counter feature.We mutate the object in the serialization implementation which
means the next time you observe the value the labels object has
been incorrectly mutated.
The functionality of
.labels()
is supposed to be the cachingof the labels object itself instead of constantly re-using it.
I may actually be the only one using the caching feature of the
.labels()
method which is why this bug was not caught earlier.The
.labels()
method is not broken if you use it asBut is broken if you do