Overview of Micrometer Observation API
The Micrometer Observation API allows developers to instrument their code once and produce multiple types of telemetry (such as metrics, distributed tracing spans, and logs) by reacting to the lifecycle of an 'Observation'.
Key concepts include:
- ObservationRegistry: The central registry containing configuration, handlers, filters, and predicates.
- ObservationHandler: Reacts to lifecycle events to create timers, spans, or logs. It only triggers if it supports the specific
Observation.Contextimplementation. - Observation.Context: A mutable map attached to an Observation used to pass state between handlers without relying on thread locals.
- ObservationConvention: Separates the lifecycle operations from the configuration (naming and metadata), allowing naming conventions to be changed without modifying instrumentation code.
- ObservationFilter: Mutates the Context before an Observation stops (e.g., adding environment metadata).
- ObservationPredicate: A condition used to determine if an Observation should be created or disabled.