Skip to content

Feature Request: Add a way to get the last measurement #825

@carl-mastrangelo

Description

@carl-mastrangelo

When unit testing that counters, gauges, and other meters are correctly updated, it's verbose to get the latest numbers. I think it would be useful to provide a way to get the last measurement value on a meter. Currently, I call Meter.measure, sort the entries by timestamp, and pick the last one.

One way to fix this would be a lastMeasurement default method on the interface, that does effectively the same thing. Individual implementations that keep an ordered list of measurements can override it and provide an optimized variant. This would allow me to build an "expected" and "actual" measurement map, from Id to Double. I could compare the two maps to ensure they match in my tests.

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