-
Notifications
You must be signed in to change notification settings - Fork 524
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
distributor: remove labels with empty values #2439
Conversation
4ba73d7
to
de73c7d
Compare
CHANGELOG.md
Outdated
@@ -18,6 +18,7 @@ | |||
* [ENHANCEMENT] Object storage can now be configured for all components using the `common` YAML config option key (or `-common.storage.*` CLI flags). #2330 | |||
* [ENHANCEMENT] Go: updated to go 1.18.4. #2400 | |||
* [ENHANCEMENT] Store-gateway, listblocks: list of blocks now includes stats from `meta.json` file: number of series, samples and chunks. #2425 | |||
* [ENHANCEMENT] Distributor: remove labels with empty values #2439 |
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.
* [ENHANCEMENT] Distributor: remove labels with empty values #2439 | |
* [ENHANCEMENT] Distributor: remove labels with empty values. #2439 |
@@ -506,6 +506,15 @@ func removeLabel(labelName string, labels *[]mimirpb.LabelAdapter) { | |||
} | |||
} | |||
|
|||
// Remove labels with value=="" from a slice of LabelPairs, updating the slice in-place. | |||
func removeEmptyLabelValues(labels *[]mimirpb.LabelAdapter) { | |||
for i := len(*labels) - 1; i >= 0; i-- { |
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 there be any performance difference when processing labels from the beginning vs from the end?
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.
I suspect the idea was if we have a, b, c, d, e
and we're going to remove b
and d
, then going forwards means we copy d
before removing it, whereas going backwards avoids that.
Also, going forward you need to not increment i
if you removed an item.
de73c7d
to
6c59b05
Compare
The CHANGELOG has just been cut to prepare for the next Mimir release. Please rebase |
Empty labels are stripped when the series reaches TSDB, so we should remove them earlier to keep things consistent.
6c59b05
to
e124e1c
Compare
Rebased against latest |
Signed-off-by: Marco Pracucci <marco@pracucci.com>
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, thanks! I hope you don't mind I've committed few more test cases.
* distributor: remove labels with empty values Empty labels are stripped when the series reaches TSDB, so we should remove them earlier to keep things consistent. * Added more test cases Signed-off-by: Marco Pracucci <marco@pracucci.com> Signed-off-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: Marco Pracucci <marco@pracucci.com>
Empty labels are stripped when the series reaches TSDB, so we should remove them earlier to keep things consistent.
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]