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
Nested ClassesModifier and TypeInterfaceDescriptionstatic classHandler picking all matching handlers from the list.static interfaceHandler wrapping other handlers.static classHandler picking the first matching handler from the list. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidReacts to an error during anObservation.default voidonEvent(Observation.Event event, T context) Reacts to arbitraryObservation.Event.default voidonScopeClosed(T context) Reacts to closing of anObservation.Scope.default voidonScopeOpened(T context) Reacts to opening of anObservation.Scope.default voidonScopeReset(T context) Reacts to resetting of scopes.default voidReacts to starting of anObservation.default voidReacts to stopping of anObservation.booleansupportsContext(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.Eventthat 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 aThreadLocalvalue, this method should clear thatThreadLocalor 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:
truewhen this handler should be used
-