Package io.micrometer.observation
Interface ObservationHandler<T extends Observation.Context>
- Type Parameters:
T
- type of context
- All Known Subinterfaces:
ObservationHandler.CompositeObservationHandler
- All Known Implementing Classes:
ObservationHandler.AllMatchingCompositeObservationHandler
,ObservationHandler.FirstMatchingCompositeObservationHandler
,ObservationTextPublisher
public interface ObservationHandler<T extends Observation.Context>
Handler for an
Observation
. Hooks in to the lifecycle of an observation.
Example of handler implementations can create metrics, spans or logs.- Since:
- 1.10.0
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Handler picking all matching handlers from the list.static interface
Handler wrapping other handlers.static class
Handler picking the first matching handler from the list. -
Method Summary
Modifier and TypeMethodDescriptiondefault void
Reacts to an error during anObservation
.default void
onEvent
(Observation.Event event, T context) Reacts to arbitraryObservation.Event
.default void
onScopeClosed
(T context) Reacts to closing of anObservation.Scope
.default void
onScopeOpened
(T context) Reacts to opening of anObservation.Scope
.default void
onScopeReset
(T context) Reacts to resetting of scopes.default void
Reacts to starting of anObservation
.default void
Reacts to stopping of anObservation
.boolean
supportsContext
(Observation.Context context) Tells the registry whether this handler should be applied for a givenObservation.Context
.
-
Method Details
-
onStart
Reacts to starting of anObservation
.- Parameters:
context
- anObservation.Context
-
onError
Reacts to an error during anObservation
.- Parameters:
context
- anObservation.Context
-
onEvent
Reacts to arbitraryObservation.Event
.- Parameters:
event
- theObservation.Event
that was signaledcontext
- anObservation.Context
-
onScopeOpened
Reacts to opening of anObservation.Scope
.- Parameters:
context
- anObservation.Context
-
onScopeClosed
Reacts to closing of anObservation.Scope
.- Parameters:
context
- anObservation.Context
-
onScopeReset
Reacts to resetting of scopes. If your handler uses aThreadLocal
value, this method should clear thatThreadLocal
or any other scoped variable.- Parameters:
context
- anObservation.Context
- Since:
- 1.10.4
-
onStop
Reacts to stopping of anObservation
.- Parameters:
context
- anObservation.Context
-
supportsContext
Tells the registry whether this handler should be applied for a givenObservation.Context
.- Parameters:
context
- anObservation.Context
- Returns:
true
when this handler should be used
-