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 TypeMethodDescriptionvoid
onError
(Observation.Context context) Reacts to an error during anObservation
.void
onEvent
(Observation.Event event, Observation.Context context) Reacts to arbitraryObservation.Event
.void
onScopeClosed
(Observation.Context context) Reacts to closing of anObservation.Scope
.void
onScopeOpened
(Observation.Context context) Reacts to opening of anObservation.Scope
.void
onStart
(Observation.Context context) Reacts to starting of anObservation
.void
onStop
(Observation.Context context) Reacts to stopping of anObservation
.boolean
supportsContext
(Observation.Context context) Tells the registry whether this handler should be applied for a givenObservation.Context
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micrometer.observation.ObservationHandler
onScopeReset
-
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 givenConsumer
if thePredicate
returns 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 givenConsumer
if thePredicate
returns true.- Parameters:
consumer
- Where to publish the context as textsupportsContextPredicate
- Whether the publisher should support the given contextconverter
- Converts theObservation.Context
to aString
-
-
Method Details
-
onStart
Description copied from interface:ObservationHandler
Reacts to starting of anObservation
.- Specified by:
onStart
in interfaceObservationHandler<Observation.Context>
- Parameters:
context
- anObservation.Context
-
onError
Description copied from interface:ObservationHandler
Reacts to an error during anObservation
.- Specified by:
onError
in interfaceObservationHandler<Observation.Context>
- Parameters:
context
- anObservation.Context
-
onEvent
Description copied from interface:ObservationHandler
Reacts to arbitraryObservation.Event
.- Specified by:
onEvent
in interfaceObservationHandler<Observation.Context>
- Parameters:
event
- theObservation.Event
that was signaledcontext
- anObservation.Context
-
onScopeOpened
Description copied from interface:ObservationHandler
Reacts to opening of anObservation.Scope
.- Specified by:
onScopeOpened
in interfaceObservationHandler<Observation.Context>
- Parameters:
context
- anObservation.Context
-
onScopeClosed
Description copied from interface:ObservationHandler
Reacts to closing of anObservation.Scope
.- Specified by:
onScopeClosed
in interfaceObservationHandler<Observation.Context>
- Parameters:
context
- anObservation.Context
-
onStop
Description copied from interface:ObservationHandler
Reacts to stopping of anObservation
.- Specified by:
onStop
in interfaceObservationHandler<Observation.Context>
- Parameters:
context
- anObservation.Context
-
supportsContext
Description copied from interface:ObservationHandler
Tells the registry whether this handler should be applied for a givenObservation.Context
.- Specified by:
supportsContext
in interfaceObservationHandler<Observation.Context>
- Parameters:
context
- anObservation.Context
- Returns:
true
when this handler should be used
-