Skip to content

Lack of consistency in retrieval of observed values #235

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

Closed
iustin opened this issue Nov 1, 2024 · 4 comments
Closed

Lack of consistency in retrieval of observed values #235

iustin opened this issue Nov 1, 2024 · 4 comments

Comments

@iustin
Copy link

iustin commented Nov 1, 2024

Hi,

Looking at the library, it looks like:

  • Counter and Gauge allow retrieving the current value.
  • Family half-allows it - there's get_or_create, but that has the side-effect of creating the value if non-existent.
  • Histogram and Info don't allow it at all.

Now, in production, there's not much use, but in tests, I'd rather be able to test the values directly rather than encode and parse back the text format. Would you mind a pull request allowing clean retrieval of:

  • Info string
  • Histogram count and sum?

Thanks!

@mxinden
Copy link
Member

mxinden commented Feb 9, 2025

Family half-allows it - there's get_or_create, but that has the side-effect of creating the value if non-existent.

Note that there is Family::get now: #234

Histogram count and sum?

See discussion in #242

@iustin
Copy link
Author

iustin commented Feb 13, 2025

Thanks, then I'll subscribe to the histogram count and sum pull request.

There's still the question of retrieving info strings, unless I'm mistaken?

@mxinden
Copy link
Member

mxinden commented Feb 14, 2025

There's still the question of retrieving info strings, unless I'm mistaken?

I assume you don't want to retrieve the value of an Info metric, since that will always be 1.

Existence of a Info metric label combination in e.g. a Family you can test via Family::get:

https://docs.rs/prometheus-client/latest/prometheus_client/metrics/family/struct.Family.html#method.get

@iustin
Copy link
Author

iustin commented Feb 19, 2025

Excellent, thanks for the explanation. Then I'll close this in favour of watching the remaining pull request.

@iustin iustin closed this as completed Feb 19, 2025
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