Skip to content

Please allow f64 counters #599

@peterbourgon

Description

@peterbourgon

I've seen #367 but want to raise this issue again.

As mentioned in that issue: counters, gauges, and histograms are all well-defined to have the same value type, which is f64. By constraining counter! to u64, metrics-rs makes it impossible to model many common counter use cases. For example, anything involving time is expected to use the unit of "seconds", but without sub-second (i.e. f64) precision, this isn't feasible.

I appreciate the desire to use the type system to prevent negative counter increments, and that's fine as an option, even a default option. But you can still enforce monotonicity for f64 counters! Just at runtime, instead of compile time. Which is totally fine. And, really, necessary.

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