Package io.micrometer.observation
Class ObservationTextPublisher
java.lang.Object
io.micrometer.observation.ObservationTextPublisher
- All Implemented Interfaces:
ObservationHandler<Observation.Context>
public class ObservationTextPublisher
extends Object
implements ObservationHandler<Observation.Context>
An
ObservationHandler that converts the context to text and publishes it to the
Consumer of your choice.- Since:
- 1.10.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micrometer.observation.ObservationHandler
ObservationHandler.AllMatchingCompositeObservationHandler, ObservationHandler.CompositeObservationHandler, ObservationHandler.FirstMatchingCompositeObservationHandler -
Constructor Summary
ConstructorsConstructorDescriptionCreates a publisher that sends the context as text to the givenConsumer.ObservationTextPublisher(Consumer<String> consumer) Creates a publisher that sends the context as text to the givenConsumer.ObservationTextPublisher(Consumer<String> consumer, Predicate<Observation.Context> supportsContextPredicate) ObservationTextPublisher(Consumer<String> consumer, Predicate<Observation.Context> supportsContextPredicate, Function<Observation.Context, String> converter) -
Method Summary
Modifier and TypeMethodDescriptionvoidonError(Observation.Context context) Reacts to an error during anObservation.voidonEvent(Observation.Event event, Observation.Context context) Reacts to arbitraryObservation.Event.voidonScopeClosed(Observation.Context context) Reacts to closing of anObservation.Scope.voidonScopeOpened(Observation.Context context) Reacts to opening of anObservation.Scope.voidonStart(Observation.Context context) Reacts to starting of anObservation.voidonStop(Observation.Context context) Reacts to stopping of anObservation.booleansupportsContext(Observation.Context context) Tells the registry whether this handler should be applied for a givenObservation.Context.
-
Constructor Details
-
ObservationTextPublisher
public ObservationTextPublisher()Creates a publisher that sends the context as text to the givenConsumer. -
ObservationTextPublisher
Creates a publisher that sends the context as text to the givenConsumer.- Parameters:
consumer- Where to publish the context as text
-
ObservationTextPublisher
public ObservationTextPublisher(Consumer<String> consumer, Predicate<Observation.Context> supportsContextPredicate) Creates a publisher that sends the context as text to the givenConsumerif thePredicatereturns true.- Parameters:
consumer- Where to publish the context as textsupportsContextPredicate- Whether the publisher should support the given context
-
ObservationTextPublisher
public ObservationTextPublisher(Consumer<String> consumer, Predicate<Observation.Context> supportsContextPredicate, Function<Observation.Context, String> converter) Creates a publisher that sends the context as text to the givenConsumerif thePredicatereturns true.- Parameters:
consumer- Where to publish the context as textsupportsContextPredicate- Whether the publisher should support the given contextconverter- Converts theObservation.Contextto aString
-
-
Method Details
-
onStart
Description copied from interface:ObservationHandlerReacts to starting of anObservation.- Specified by:
onStartin interfaceObservationHandler<Observation.Context>- Parameters:
context- anObservation.Context
-
onError
Description copied from interface:ObservationHandlerReacts to an error during anObservation.- Specified by:
onErrorin interfaceObservationHandler<Observation.Context>- Parameters:
context- anObservation.Context
-
onEvent
Description copied from interface:ObservationHandlerReacts to arbitraryObservation.Event.- Specified by:
onEventin interfaceObservationHandler<Observation.Context>- Parameters:
event- theObservation.Eventthat was signaledcontext- anObservation.Context
-
onScopeOpened
Description copied from interface:ObservationHandlerReacts to opening of anObservation.Scope.- Specified by:
onScopeOpenedin interfaceObservationHandler<Observation.Context>- Parameters:
context- anObservation.Context
-
onScopeClosed
Description copied from interface:ObservationHandlerReacts to closing of anObservation.Scope.- Specified by:
onScopeClosedin interfaceObservationHandler<Observation.Context>- Parameters:
context- anObservation.Context
-
onStop
Description copied from interface:ObservationHandlerReacts to stopping of anObservation.- Specified by:
onStopin interfaceObservationHandler<Observation.Context>- Parameters:
context- anObservation.Context
-
supportsContext
Description copied from interface:ObservationHandlerTells the registry whether this handler should be applied for a givenObservation.Context.- Specified by:
supportsContextin interfaceObservationHandler<Observation.Context>- Parameters:
context- anObservation.Context- Returns:
truewhen this handler should be used
-