Abstraction for instrumentating with a Timer or Observation (optionally) by shakuzen · Pull Request #3357 · micrometer-metrics/micrometer (original) (raw)
…tion (optionally)
We have a lot of existing instrumentations with Timer that are good candidates to be rewritten with the Observation API for added extensibility. However, we cannot break compatibility for existing users by requiring an ObservationRegistry for each instrumentation. We will want to add an option to configure an ObservationRegistry on the builder for the instrumentation or as an additional constructor if there isn't a builder. Instrumentation should still work as before without providing an ObservationRegistry. This can be handled in each instrumentation, but this added class ObservationOrTimerCompatibleInstrumentation is intended to make it easier to support this case where instrumentation may be done with a Timer or Observation depending on whether an ObservationRegistry is available. By having a common abstraction for this, we can hopefully make supporting Observation in our existing instrumentations easier, and also avoid adding overhead to instrumentation by avoiding instantiating things for Observation when a Timer is used (and the opposite situation).