fix(prometheus): stabilize label maps in MetricVec.GetMetricWith#2024
Closed
immanuwell wants to merge 1 commit into
Closed
fix(prometheus): stabilize label maps in MetricVec.GetMetricWith#2024immanuwell wants to merge 1 commit into
immanuwell wants to merge 1 commit into
Conversation
Signed-off-by: immanuwell <pchpr.00@list.ru>
341c274 to
12770f7
Compare
Member
|
Thanks but we prefer performance vs making it ultra safe for all cases. However some commentary would be useful. See #1951 (comment) Feel free to push back, we can always reopen 🤗 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #1951
cc @vesari
GetMetricWith(Labels)could hash one label set, then store another if the same map gets mutated while the metric is being created. that can bubble up ascollected before with the same name and label values, kind of nasty.This stabilizes the map input first, then reuses the label values path.
WithLabelValues(...)stays as is.Repro:
go test ./prometheus -run TestMetricVecWithLabelsKeepsLabelValuesStable -count=1collected metric "test" ... was collected before with the same name and label valuesChecks:
go test ./...cd exp && go test ./...go test -race ./prometheus -run 'TestMetricVecWithLabelsKeepsLabelValuesStable|TestMetricVecWithConstraints|TestCurryVec|TestCurryVecWithConstraints|TestDelete|TestDeleteLabelValues|TestDeletePartialMatch' -count=1