Skip to content

Metric handles should be typed #122

@ScottMansfield

Description

@ScottMansfield

Right now the metric handles are not specially typed, they are just uint32s. In order to make the metric API clearer and reduce the likelihood of it being accidentally misused, the Add* functions should return typed handles, e.g. metrics.CounterHandle. The corresponding functions to record measurements will change to accept only their typed handles. This will apply to Counters, Gauges, and Histograms, each with their own types.

Of course this does not prevent someone from explicitly misusing the API, but it does prevent someone from e.g. trying to increment a counter using a gauge ID accidentally, which can crash the program.

The vast majority of code should not be affected by this change, as they should mostly be using the Add* methods in var blocks and then using those in the code below.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions