eclipse / microprofile-metrics

microprofile-metrics
Apache License 2.0
100 stars 66 forks source link

Address the redundancy of units for the Timer metric #759

Closed Channyboy closed 1 year ago

Channyboy commented 1 year ago

The specification and java doc specifies that the default unit for the Timer metric is nanoseconds. However, the unit bears no significance for Timer metric whatsoever and serves only to confuse users. The Timer interface indicates that explicit API calls to update and retrieve times is through the Java Duration object. However, it should be noted that timing with context will return a long which indicates how many nanoseconds transpired when the stop() method of the context is called. Similarily, interacting with the underlying Snapshot will provide values in nanoseconds. Yet ultimately, the formatted result in Prometheus is in seconds.

Units, however, may still be useful to non Prometheus registries.

Channyboy commented 1 year ago

As units may be useful for non-prometheus monitoring tools, the Timer will keep the use of units.