temporal icon indicating copy to clipboard operation
temporal copied to clipboard

Migrate usage of metrics.Handler to metricDefinition.With

Open luansapelli opened this issue 2 years ago • 0 comments

What changed?

Using the new metricDefinition.With approach.

Why?

The usage of metrics.Handler could be both redundant and unsafe:

 handler.Histogram( myHisto.Name(), myHisto.Unit() ).Record(...)
                │             │               └───┐
                │             │                   │
                └─────┐       └───────────┐       │
                      │                   │       │
       Redundant and Unsafe: 'Histogram'  │       │
       is specified despite knowing       │       │
       'myHisto' is a histogram. There's  │       │
       also a risk if 'myHisto.Name()'    │       │
       refers to a metric definition that │       │
       is not a histogram.                │       │
                                          └─── Redundant information

And using the new With(Handler) method, there's no need to specify redundant information.

How did you test it?

Already exists an ExampleHandler which tests all the new approach methods.

Potential risks

People can still use the old approach, because we are keeping the Handler interface as-is.

Is hotfix candidate?

No.

luansapelli avatar Feb 19 '24 01:02 luansapelli