Top Description Inners Methods
io.micrometer.observation

public Interface ObservationHandler<T extends Observation.Context>

Known Direct Subinterfaces
io.micrometer.observation.ObservationHandler.CompositeObservationHandler
Known Direct Implementers
io.micrometer.observation.ObservationTextPublisher
Type Parameters
<T>
type of context
Imports
io.micrometer.common.lang.Nullable, io.micrometer.observation.Observation.Context, java.util.ArrayList, .Arrays, .List

Handler for an Observation. Hooks in to the lifecycle of an observation. Example of handler implementations can create metrics, spans or logs.
Authors
Jonatan Ivanov, Tommy Ludwig, Marcin Grzejszczak
Since
1.10.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ObservationHandler.AllMatchingCompositeObservationHandler

Handler picking all matching handlers from the list.

public static interface
ObservationHandler.CompositeObservationHandler

Handler wrapping other handlers.

public static class
ObservationHandler.FirstMatchingCompositeObservationHandler

Handler picking the first matching handler from the list.

Method Summary

Modifier and TypeMethod and Description
public default void
onError(T context)

Reacts to an error during an Observation.

public default void
onEvent(Observation.Event
the Observation.Event that was signaled
event
,
T context)

Reacts to arbitrary Observation.

public default void
onScopeClosed(T context)

Reacts to closing of an Observation.

public default void
onScopeOpened(T context)

Reacts to opening of an Observation.

public default void
onScopeReset(T context)

Reacts to resetting of scopes.

public default void
onStart(T context)

Reacts to starting of an Observation.

public default void
onStop(T context)

Reacts to stopping of an Observation.

public boolean

Returns:

true when this handler should be used
supportsContext
(Observation.Context context)

Tells the registry whether this handler should be applied for a given Observation.

Method Detail

onErrorback to summary
public default void onError(T context)

Reacts to an error during an Observation.

Parameters
context:T

an Observation.Context

onEventback to summary
public default void onEvent(Observation.Event event, T context)

Reacts to arbitrary Observation.Event.

Parameters
event:Observation.Event

the Observation.Event that was signaled

context:T

an Observation.Context

onScopeClosedback to summary
public default void onScopeClosed(T context)

Reacts to closing of an Observation.Scope.

Parameters
context:T

an Observation.Context

onScopeOpenedback to summary
public default void onScopeOpened(T context)

Reacts to opening of an Observation.Scope.

Parameters
context:T

an Observation.Context

onScopeResetback to summary
public default void onScopeReset(T context)

Reacts to resetting of scopes. If your handler uses a ThreadLocal value, this method should clear that ThreadLocal or any other scoped variable.

Parameters
context:T

an Observation.Context

Since
1.10.4
onStartback to summary
public default void onStart(T context)

Reacts to starting of an Observation.

Parameters
context:T

an Observation.Context

onStopback to summary
public default void onStop(T context)

Reacts to stopping of an Observation.

Parameters
context:T

an Observation.Context

supportsContextback to summary
public boolean supportsContext(Observation.Context context)

Tells the registry whether this handler should be applied for a given Observation.Context.

Parameters
context:Observation.Context

an Observation.Context

Returns:boolean

true when this handler should be used

io.micrometer.observation back to summary

public Class ObservationHandler.AllMatchingCompositeObservationHandler

extends Object
implements CompositeObservationHandler
Class Inheritance
  • java.lang.Object
  • io.micrometer.observation.ObservationHandler.AllMatchingCompositeObservationHandler
All Implemented Interfaces
io.micrometer.observation.ObservationHandler.CompositeObservationHandler, io.micrometer.observation.ObservationHandler

Handler picking all matching handlers from the list.

Field Summary

Modifier and TypeField and Description
private final List<ObservationHandler<Observation.Context>>

Constructor Summary

AccessConstructor and Description
public
AllMatchingCompositeObservationHandler(ObservationHandler<? extends Observation.Context>...
the handlers that are registered under the composite
handlers
)

Creates a new instance of AllMatchingCompositeObservationHandler.

public
AllMatchingCompositeObservationHandler(List<? extends ObservationHandler<? extends Observation.Context>>
the handlers that are registered under the composite
handlers
)

Creates a new instance of AllMatchingCompositeObservationHandler.

Method Summary

Modifier and TypeMethod and Description
public List<ObservationHandler<Observation.Context>>
public void
public void
public void
public void
public void
public void
public void
public boolean
supportsContext(Observation.Context context)

Implements io.micrometer.observation.ObservationHandler.supportsContext.

Tells the registry whether this handler should be applied for a given Observation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlersback to summary
private final List<ObservationHandler<Observation.Context>> handlers

Constructor Detail

AllMatchingCompositeObservationHandlerback to summary
public AllMatchingCompositeObservationHandler(ObservationHandler<? extends Observation.Context>... handlers)

Creates a new instance of AllMatchingCompositeObservationHandler.

Parameters
handlers:ObservationHandler<? extends Observation.Context>[]

the handlers that are registered under the composite

Annotations
@SafeVarargs
AllMatchingCompositeObservationHandlerback to summary
public AllMatchingCompositeObservationHandler(List<? extends ObservationHandler<? extends Observation.Context>> handlers)

Creates a new instance of AllMatchingCompositeObservationHandler.

Parameters
handlers:List<? extends ObservationHandler<? extends Observation.Context>>

the handlers that are registered under the composite

Annotations
@SuppressWarnings:unchecked

Method Detail

getHandlersback to summary
public List<ObservationHandler<Observation.Context>> getHandlers()

Implements io.micrometer.observation.ObservationHandler.CompositeObservationHandler.getHandlers.

Doc from io.micrometer.observation.ObservationHandler.CompositeObservationHandler.getHandlers.

Returns the registered handlers.

Returns:List<ObservationHandler<Observation.Context>>

registered handlers

Annotations
@Override
onErrorback to summary
public void onError(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onError.

Doc from io.micrometer.observation.ObservationHandler.onError.

Reacts to an error during an Observation.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onEventback to summary
public void onEvent(Observation.Event event, Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onEvent.

Doc from io.micrometer.observation.ObservationHandler.onEvent.

Reacts to arbitrary Observation.Event.

Parameters
event:Observation.Event

the Observation.Event that was signaled

context:Observation.Context

an Observation.Context

Annotations
@Override
onScopeClosedback to summary
public void onScopeClosed(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onScopeClosed.

Doc from io.micrometer.observation.ObservationHandler.onScopeClosed.

Reacts to closing of an Observation.Scope.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onScopeOpenedback to summary
public void onScopeOpened(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onScopeOpened.

Doc from io.micrometer.observation.ObservationHandler.onScopeOpened.

Reacts to opening of an Observation.Scope.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onScopeResetback to summary
public void onScopeReset(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onScopeReset.

Doc from io.micrometer.observation.ObservationHandler.onScopeReset.

Reacts to resetting of scopes. If your handler uses a ThreadLocal value, this method should clear that ThreadLocal or any other scoped variable.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onStartback to summary
public void onStart(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onStart.

Doc from io.micrometer.observation.ObservationHandler.onStart.

Reacts to starting of an Observation.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onStopback to summary
public void onStop(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onStop.

Doc from io.micrometer.observation.ObservationHandler.onStop.

Reacts to stopping of an Observation.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
supportsContextback to summary
public boolean supportsContext(Observation.Context context)

Implements io.micrometer.observation.ObservationHandler.supportsContext.

Doc from io.micrometer.observation.ObservationHandler.supportsContext.

Tells the registry whether this handler should be applied for a given Observation.Context.

Parameters
context:Observation.Context

an Observation.Context

Returns:boolean

true when this handler should be used

Annotations
@Override
io.micrometer.observation back to summary

public Interface ObservationHandler.CompositeObservationHandler

extends ObservationHandler<Observation.Context>
Known Direct Implementers
io.micrometer.observation.ObservationHandler.FirstMatchingCompositeObservationHandler, io.micrometer.observation.ObservationHandler.AllMatchingCompositeObservationHandler

Handler wrapping other handlers.

Method Summary

Modifier and TypeMethod and Description
public List<ObservationHandler<Observation.Context>>

Returns:

registered handlers
getHandlers
()

Returns the registered handlers.

Inherited from io.micrometer.observation.ObservationHandler:
onErroronEventonScopeClosedonScopeOpenedonScopeResetonStartonStopsupportsContext

Method Detail

getHandlersback to summary
public List<ObservationHandler<Observation.Context>> getHandlers()

Returns the registered handlers.

Returns:List<ObservationHandler<Observation.Context>>

registered handlers

io.micrometer.observation back to summary

public Class ObservationHandler.FirstMatchingCompositeObservationHandler

extends Object
implements CompositeObservationHandler
Class Inheritance
  • java.lang.Object
  • io.micrometer.observation.ObservationHandler.FirstMatchingCompositeObservationHandler
All Implemented Interfaces
io.micrometer.observation.ObservationHandler.CompositeObservationHandler, io.micrometer.observation.ObservationHandler

Handler picking the first matching handler from the list.

Field Summary

Modifier and TypeField and Description
private final List<ObservationHandler<Observation.Context>>

Constructor Summary

AccessConstructor and Description
public
FirstMatchingCompositeObservationHandler(ObservationHandler<? extends Observation.Context>...
the handlers that are registered under the composite
handlers
)

Creates a new instance of FirstMatchingCompositeObservationHandler.

public
FirstMatchingCompositeObservationHandler(List<? extends ObservationHandler<? extends Observation.Context>>
the handlers that are registered under the composite
handlers
)

Creates a new instance of FirstMatchingCompositeObservationHandler.

Method Summary

Modifier and TypeMethod and Description
private ObservationHandler<Observation.Context>
public List<ObservationHandler<Observation.Context>>
public void
public void
public void
public void
public void
public void
public void
public boolean
supportsContext(Observation.Context context)

Implements io.micrometer.observation.ObservationHandler.supportsContext.

Tells the registry whether this handler should be applied for a given Observation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlersback to summary
private final List<ObservationHandler<Observation.Context>> handlers

Constructor Detail

FirstMatchingCompositeObservationHandlerback to summary
public FirstMatchingCompositeObservationHandler(ObservationHandler<? extends Observation.Context>... handlers)

Creates a new instance of FirstMatchingCompositeObservationHandler.

Parameters
handlers:ObservationHandler<? extends Observation.Context>[]

the handlers that are registered under the composite

Annotations
@SafeVarargs
FirstMatchingCompositeObservationHandlerback to summary
public FirstMatchingCompositeObservationHandler(List<? extends ObservationHandler<? extends Observation.Context>> handlers)

Creates a new instance of FirstMatchingCompositeObservationHandler.

Parameters
handlers:List<? extends ObservationHandler<? extends Observation.Context>>

the handlers that are registered under the composite

Annotations
@SuppressWarnings:unchecked

Method Detail

getFirstApplicableHandlerback to summary
private ObservationHandler<Observation.Context> getFirstApplicableHandler(Observation.Context context)
Annotations
@Nullable
getHandlersback to summary
public List<ObservationHandler<Observation.Context>> getHandlers()

Implements io.micrometer.observation.ObservationHandler.CompositeObservationHandler.getHandlers.

Doc from io.micrometer.observation.ObservationHandler.CompositeObservationHandler.getHandlers.

Returns the registered handlers.

Returns:List<ObservationHandler<Observation.Context>>

registered handlers

Annotations
@Override
onErrorback to summary
public void onError(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onError.

Doc from io.micrometer.observation.ObservationHandler.onError.

Reacts to an error during an Observation.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onEventback to summary
public void onEvent(Observation.Event event, Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onEvent.

Doc from io.micrometer.observation.ObservationHandler.onEvent.

Reacts to arbitrary Observation.Event.

Parameters
event:Observation.Event

the Observation.Event that was signaled

context:Observation.Context

an Observation.Context

Annotations
@Override
onScopeClosedback to summary
public void onScopeClosed(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onScopeClosed.

Doc from io.micrometer.observation.ObservationHandler.onScopeClosed.

Reacts to closing of an Observation.Scope.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onScopeOpenedback to summary
public void onScopeOpened(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onScopeOpened.

Doc from io.micrometer.observation.ObservationHandler.onScopeOpened.

Reacts to opening of an Observation.Scope.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onScopeResetback to summary
public void onScopeReset(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onScopeReset.

Doc from io.micrometer.observation.ObservationHandler.onScopeReset.

Reacts to resetting of scopes. If your handler uses a ThreadLocal value, this method should clear that ThreadLocal or any other scoped variable.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onStartback to summary
public void onStart(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onStart.

Doc from io.micrometer.observation.ObservationHandler.onStart.

Reacts to starting of an Observation.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
onStopback to summary
public void onStop(Observation.Context context)

Overrides default io.micrometer.observation.ObservationHandler.onStop.

Doc from io.micrometer.observation.ObservationHandler.onStop.

Reacts to stopping of an Observation.

Parameters
context:Observation.Context

an Observation.Context

Annotations
@Override
supportsContextback to summary
public boolean supportsContext(Observation.Context context)

Implements io.micrometer.observation.ObservationHandler.supportsContext.

Doc from io.micrometer.observation.ObservationHandler.supportsContext.

Tells the registry whether this handler should be applied for a given Observation.Context.

Parameters
context:Observation.Context

an Observation.Context

Returns:boolean

true when this handler should be used

Annotations
@Override