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 label order when incrementing ingester discarded metadata metric #2096

Merged
merged 6 commits into from
Jun 17, 2022

Conversation

pr00se
Copy link
Contributor

@pr00se pr00se commented Jun 14, 2022

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 the validation package, the order should be (reason, user).

Which issue(s) this PR fixes or relates to

N/A

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@pr00se pr00se force-pushed the fix-metadata-limit-labels branch from 0f5716c to 47f6c2c Compare June 14, 2022 00:19
@pstibrany
Copy link
Member

Nice find! Can we add a test for this change?

@pr00se pr00se force-pushed the fix-metadata-limit-labels branch from 47f6c2c to 1effdd8 Compare June 16, 2022 07:25
@pr00se
Copy link
Contributor Author

pr00se commented Jun 16, 2022

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.

Copy link
Collaborator

@pracucci pracucci left a 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
Copy link
Collaborator

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?

pkg/ingester/ingester_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@pracucci pracucci left a 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).

@pracucci pracucci merged commit 145a664 into main Jun 17, 2022
@pracucci pracucci deleted the fix-metadata-limit-labels branch June 17, 2022 08:37
masonmei pushed a commit to udmire/mimir that referenced this pull request Jul 11, 2022
…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
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.

None yet

3 participants