-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
aggregateutil: allow filtering against empty attribute set #35006
base: main
Are you sure you want to change the base?
Conversation
It is a valid use case to aggregate against an empty label set, which will functionally clear all attributes. This behaviour was removed in a previous PR, which simplified the check to `len() == 0`, which covers the case of the label set being `nil` and having 0 elements the same. However, these are not the same scenario and have different meanings. This PR reintroduces the original behaviour, but in a more efficient way by recognizing a label set with 0 elements and clearing the attributes, which would be the logical conclusion after running the filter anyway.
CC @odubajDT |
Integration test looks like a flake to me. I don't have authority to re-run the CI with the button but I can force-push if I need to re-run. |
please run |
Is there any chance this PR can be reviewed? |
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.
@braydonk to make sure the functionality is the same as before can you also restore any tests to the metricstransformprocessor that covers this scenario.
Adds empty and nil label set tests. Exposed something I didn't notice in the way the code is called when calling from metricstransform processor compared to using the aggregateutil package functions directly.
This is done in f7c46ce. Thanks for calling it out, I should have thought of that and it did expose a problem that I fixed in that commit as well. While manually testing this along with the unit tests, I found something interesting. While in the previous version of the In f7c46ce I adjusted it to check for |
Ya lets restore the previous behavior, it doesn't sound like the way metricstransform was doing this before was a bug. |
Even before the aggregateutil change, metricstransform never passed a nil label_set to `aggregateLabelsOp`; a nil label_set would always be changed to empty slice anyway. This commit restores that behaviour.
The length of the attributes array can always be a known value. This commit pre-allocates that space to save on allocations.
Fine by me. Having a nil Restored in debfca5 |
Description:
It is a valid use case to aggregate against an empty label set, which will functionally clear all attributes. This behaviour was removed in #33655, which simplified the check to
len() == 0
, which covers the case of the label set beingnil
and having 0 elements as the same scenario. However, these are not the same scenario and have different meanings. This PR reintroduces the original behaviour, but in a more efficient way by recognizing a label set with 0 elements and clearing the attributes, which would be the logical conclusion after running the filter anyway.Link to tracking Issue: #34430
Testing:
Documentation: