-
Notifications
You must be signed in to change notification settings - Fork 532
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 label order when incrementing ingester discarded metadata metric #2096
Conversation
0f5716c
to
47f6c2c
Compare
Nice find! Can we add a test for this change? |
47f6c2c
to
1effdd8
Compare
Tests added. When writing them I discovered another bug where we were using the address of a loop variable (which is always the same) to append items to a list, resulting in a list of multiple copies of the same metadata, rather than a list of different metadatas. I shadowed the variable in the loop so we'd return the address of a copy of the data, but let me know if there's a different pattern we typically follow. |
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.
Good job finding and fixing these issues! I left a couple of comments about tests.
@@ -93,6 +93,7 @@ func (mm *userMetricsMetadata) toClientMetadata() []*mimirpb.MetricMetadata { | |||
r := make([]*mimirpb.MetricMetadata, 0, len(mm.metricToMetadata)) | |||
for _, set := range mm.metricToMetadata { | |||
for m := range set { | |||
m := m |
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.
Can we have a unit test covering this regression too, please?
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.
LGTM! I still would like to see a unit test on the userMetricsMetadata.toClientMetadata()
regression, but you can do it in a follow up PR (given you're PTO today and I want this fix in next week release).
…rafana#2096) * Use proper label order when incrementing ingester discarded metadata metric * Update CHANGELOG * Shadow a loop variable so we can return its address * Add tests for metadata limits * Update CHANGELOG * Set replication factor to 1 in ingester tests
What this PR does
Corrects the order of the labels applied when incrementing the
cortex_discarded_metadata_total
metric in the ingesters. As defined in thevalidation
package, the order should be(reason, user)
.Which issue(s) this PR fixes or relates to
N/A
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]