| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Signed-off-by: Hazel <hazel@hazel.localdomain>
There was a problem hiding this comment.
Thanks! A couple comments/questions to start with
Sorry, something went wrong.
| if labelvalues in self._metrics: | ||
| del self._metrics[labelvalues] | ||
|
|
||
| def remove_matching(self, partial: dict[str, str]) -> int: |
There was a problem hiding this comment.
What would you think of remove_partial_match for the name of this function? When I first see matching I think that all labelnames/values need to match to be removed not a partial. The name of the variable helps, but could also then be labels instead of partial which helps with confusion around thinking it could be a partial function.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for the suggestion! I’ve renamed the method to remove_by_labels and the argument to labels.
I also added a short docstring to clarify that this removes series where the provided (key, value) pairs are a partial match of the labelset.
This should reduce confusion with full-match semantics.
Sorry, something went wrong.
|
|
||
| pos_filter = {self._labelnames.index(k): str(v) for k, v in partial.items()} | ||
|
|
||
| deleted = 0 |
There was a problem hiding this comment.
What's the reasoning for returning the number of deleted items? We don't do that in remove today, but if there is a good use case I am not opposed.
Sorry, something went wrong.
There was a problem hiding this comment.
Good point on consistency. The initial version returned the number of deleted series, but I’ve updated it to return None, matching the behavior of remove(): idempotent and a no-op if nothing matches.
If there’s a strong use case for counts in the future, I’m happy to follow up with a separate helper that reports the number of removed series, without changing the main API.
Sorry, something went wrong.
Signed-off-by: Hazel <hazel@hazel.localdomain>
Signed-off-by: Hazel <hazel@hazel.localdomain>
|
Thanks for the updated code, @csmarchbanks could we get another review on this PR? |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
Fixes #1118
This PR introduces a new remove_by_labels() method to allow removing metric samples by matching a set of label values.
Changes
Motivation
Currently, the Python client does not support removing metrics with specific label values without clearing the whole metric. This feature enables more granular control, which can be useful for scenarios such as:
Example Usage
@csmarchbanks Would you take a look when you have a chance?