Skip to content

Lack of consistency in retrieval of observed values #235

Closed

Description

@iustin

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!

Activity

  1. mxinden commented on Feb 9, 2025

    @mxinden
    Member

    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

  2. iustin commented on Feb 13, 2025

    @iustin
    Author

    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?

  3. mxinden commented on Feb 14, 2025

    @mxinden
    Member

    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

  4. iustin commented on Feb 19, 2025

    @iustin
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions