-
Notifications
You must be signed in to change notification settings - Fork 150
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
Allow to delete a given set of labels from metrics #80
Conversation
This will allow to expose transient metrics. Their existence might become irrelevant through the application lifecycle. Change-Id: Ic0cb980558ffe8eb316198a7ddb8eae983444e54
@grobie any feedback on the PR? |
+1 for this feature. |
@grobie I'm willing to update the PR the fix the conflicts if you give me some feedback first. Would you be interested by this change? |
@kamaradclimber Sorry for the late response. The problem is, that label sets should be stable for an application in general. The exception are usually exporters which proxy metrics from a different system, exactly as @kazegusuri described. The proper design for that would be use constant metrics like in the golang client. The ruby client doesn't support that concept at all, and a rewrite has been discussed for a long time. I feel a bit unsure about adding something to the client we generally consider to be an anti-pattern. On the other hand, the whole client will probably change a lot with the future rewrite anyway. |
There are valid use cases for this, but they are extremely rare (as in I've came across 2 ever) outside of tests. |
My current example: We could let label set exist but it would have a non bounded memory footprint on the exporter. Feel free to advise better pattern if there is any |
That's a case where you want to use const metrics. I don't believe offhand that the ruby client supports them, but Go/Python/Java do. See https://www.robustperception.io/setting-a-prometheus-counter/ |
I've got a similar situation -- I'm translating a set of dynamically configured data sources into some prometheus metrics, and it'd be really fantastic to be able to unset a particularly labelled value. I've resorted to unregistering & reregistering the metric, and essentially replaying the values which should remain. It's pretty gross, so having an alternative (whether it's const metrics, or merging this PR) would be lovely! |
As it stands you should switch to the Go/Python/Java client which support the relevant features. This PR doesn't help you with that, though the Ruby client will likely support those features at some point. |
Unfortunately, reimplementing my application using another language isn't currently an option... I'm not sure why you say this PR wouldn't help -- it seems like it's exactly what I need! |
An exporter should not maintain state across scrapes, and this PR only helps you if you're maintaining state across scrapes. |
@brian-brazil , thanks for your comments. Could you explain your statement about exporter that should not maintain state. |
That's getting into developer questions, which are better suited for the prometheus-developer mailing list rather than going off-topic here. |
My exporter doesn't maintain state across scrapes -- it's the prometheus-client Registry that is the problem. In other words, I could destroy and re-create all of my metrics on every scrape to work around this, but that seems pretty inefficient. |
@brian-brazil I'm going through all the PR's in this repo to make a decision on what to do about each of these issues. Looking at the Labels section, there's this:
My interpretation of that line about Is this something that has changed in the best practices since the time this PR was opened? Or am I misunderstanding the Best Practices? |
That bit of the best practices likely needs some reconsidering. There are use cases for this, but they're very very rare. Mostly the people looking for this actually want const metrics. |
@kamaradclimber @uberjay I don't have a very strong opinion on this change. That said, this code will definitely not work on the current version of I think the best things to do here is close this PR, open an issue about this, and move the conversation there. Will do that next. |
This will allow to expose transient metrics. Their existence might
become irrelevant through the application lifecycle.