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

Implement deletion based on partially matching labels #1013

Merged
merged 14 commits into from Apr 21, 2022

Conversation

stone-z
Copy link
Contributor

@stone-z stone-z commented Mar 25, 2022

Towards #834. This is an approach which I think feels user-friendly and accomplishes what folks were asking for. Open to suggestions of course, I'm new here.

This PR introduces a new deletion method:

  • DeletePartialMatch(labels Labels) - deletes a metric if all of the given labels and associated values are present in that metric.

It returns the number of metrics which were deleted.

stone-z added 6 commits Mar 25, 2022
Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Zach Stone <zach@giantswarm.io>
Copy link
Member

@bwplotka bwplotka left a comment

Nice! It looks quite good to me however, I personally did not have a code that needs functionality like this. This is why it would be amazing to have opinions from potential users: @taiyang-li @pstibrany

I added a small comment though, I think the DeletePartialMatchLabelValues(values..) semantics is too open. I wonder if DeletePartialMatchLabelValues(name, values ...) make more sense (:

prometheus/vec.go Outdated Show resolved Hide resolved
stone-z added 2 commits Mar 28, 2022
Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Zach Stone <zach@giantswarm.io>
prometheus/vec_test.go Outdated Show resolved Hide resolved
prometheus/vec.go Outdated Show resolved Hide resolved
stone-z added 2 commits Mar 31, 2022
Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Zach Stone <zach@giantswarm.io>
prometheus/vec_test.go Outdated Show resolved Hide resolved
prometheus/vec_test.go Outdated Show resolved Hide resolved
prometheus/vec_test.go Outdated Show resolved Hide resolved
prometheus/vec_test.go Outdated Show resolved Hide resolved
prometheus/vec_test.go Outdated Show resolved Hide resolved
prometheus/vec_test.go Outdated Show resolved Hide resolved
@taiyang-li
Copy link

taiyang-li commented Apr 6, 2022

Nice! It looks quite good to me however, I personally did not have a code that needs functionality like this. This is why it would be amazing to have opinions from potential users: @taiyang-li @pstibrany

I added a small comment though, I think the DeletePartialMatchLabelValues(values..) semantics is too open. I wonder if DeletePartialMatchLabelValues(name, values ...) make more sense (:

This is the exact function I needed .

stone-z added 3 commits Apr 11, 2022
Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Zach Stone <zach@giantswarm.io>
@stone-z
Copy link
Contributor Author

stone-z commented Apr 11, 2022

Ok, I've updated this PR with what I think @beorn7 had in mind. I am open to returning an error if a user passes a curried label to DeletePartialMatch, but I checked and this would actually be different from Delete and DeleteLabelValues, which just return booleans. So I'm happy with this if the maintainers are as well. Thanks for your patience 🙏

@kakkoyun kakkoyun requested review from bwplotka and beorn7 Apr 13, 2022
@beorn7
Copy link
Member

beorn7 commented Apr 13, 2022

I'm aware, and this is on my review queue, but the queue is very long and progressing slowly. I'll get to this eventually, but feel free to make the call without me.

Copy link
Member

@bwplotka bwplotka left a comment

Thanks 💪🏽

Great!

@bwplotka
Copy link
Member

bwplotka commented Apr 13, 2022

I think it's safe to merge as the API got smaller and very sensible, but waiting for your eyes @beorn7 if you want to check it still. I am happy with this (:

Signed-off-by: Zach Stone <zach@giantswarm.io>
beorn7
beorn7 approved these changes Apr 19, 2022
Copy link
Member

@beorn7 beorn7 left a comment

Semantics looks OK to me now.

Copy link
Member

@kakkoyun kakkoyun left a comment

LGTM

@kakkoyun kakkoyun merged commit 4dcf02e into prometheus:main Apr 21, 2022
8 checks passed
@stone-z stone-z deleted the delete-partial-match branch Apr 21, 2022
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

5 participants