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

Provide a way to create auto-unsetting metrics #456

Open
joshualex opened this issue Sep 1, 2022 · 1 comment
Open

Provide a way to create auto-unsetting metrics #456

joshualex opened this issue Sep 1, 2022 · 1 comment

Comments

@joshualex
Copy link

I'm trying to create components that report metrics through holding an e.g. IntCounter generated from a registered IntCounterVec. I would like the set of labels attached to each component to be removed when the component is dropped, to avoid reporting the last value over and over again.

Currently this is very convoluted to achieve, since it requires holding a clone of the MetricVec, and the inner type of that MetricVec cannot be specified because it is behind a private submodule of the crate.

What is the best way to achieve this? e.g. to do something in impl Drop that will remove the set of labels for a counter, but will keep other labels intact?

@vladimir-lu
Copy link

vladimir-lu commented Apr 8, 2024

Would exposing MetricVec::reset() on the gauges help to at least provide manual GC for metric values? Was misreading the code, seems it's already exposed. I suppose you can remove the values manually when you finish a request? Would need a reference to the underlying MetricVec but seems doable? The main issue I foresee is that you probably want a time delay due if you're not pushing metrics for the scraper to pick up the values.

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

No branches or pull requests

2 participants