Top Description Fields Constructors Methods
io.micrometer.observation

public Class ObservationTextPublisher

extends Object
implements ObservationHandler<Observation.Context>
Class Inheritance
All Implemented Interfaces
io.micrometer.observation.ObservationHandler
Imports
io.micrometer.common.util.internal.logging.InternalLoggerFactory, java.util.function.Consumer, .Function, .Predicate

An ObservationHandler that converts the context to text and publishes it to the Consumer of your choice.
Author
Jonatan Ivanov
Since
1.10.0

Field Summary

Modifier and TypeField and Description
private final Consumer<String>
private final Function<Observation.Context, String>
private final Predicate<Observation.Context>

Constructor Summary

AccessConstructor and Description
public
ObservationTextPublisher()

Creates a publisher that sends the context as text to the given Consumer.

public
ObservationTextPublisher(Consumer<String>
Where to publish the context as text
consumer
)

Creates a publisher that sends the context as text to the given Consumer.

public
ObservationTextPublisher(Consumer<String>
Where to publish the context as text
consumer
,
Predicate<Observation.Context>
Whether the publisher should support the given context
supportsContextPredicate
)

Creates a publisher that sends the context as text to the given Consumer if the Predicate returns true.

public
ObservationTextPublisher(Consumer<String>
Where to publish the context as text
consumer
,
Predicate<Observation.Context>
Whether the publisher should support the given context
supportsContextPredicate
,
Function<Observation.Context, String>
Converts the Observation.Context to a String
converter
)

Creates a publisher that sends the context as text to the given Consumer if the Predicate returns true.

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
public void
public void
public void
private void
private 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

consumerback to summary
private final Consumer<String> consumer
converterback to summary
private final Function<Observation.Context, String> converter
supportsContextPredicateback to summary
private final Predicate<Observation.Context> supportsContextPredicate

Constructor Detail

ObservationTextPublisherback to summary
public ObservationTextPublisher()

Creates a publisher that sends the context as text to the given Consumer.

ObservationTextPublisherback to summary
public ObservationTextPublisher(Consumer<String> consumer)

Creates a publisher that sends the context as text to the given Consumer.

Parameters
consumer:Consumer<String>

Where to publish the context as text

ObservationTextPublisherback to summary
public ObservationTextPublisher(Consumer<String> consumer, Predicate<Observation.Context> supportsContextPredicate)

Creates a publisher that sends the context as text to the given Consumer if the Predicate returns true.

Parameters
consumer:Consumer<String>

Where to publish the context as text

supportsContextPredicate:Predicate<Observation.Context>

Whether the publisher should support the given context

ObservationTextPublisherback to summary
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 given Consumer if the Predicate returns true.

Parameters
consumer:Consumer<String>

Where to publish the context as text

supportsContextPredicate:Predicate<Observation.Context>

Whether the publisher should support the given context

converter:Function<Observation.Context, String>

Converts the Observation.Context to a String

Method Detail

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
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
publishback to summary
private void publish(String event, Observation.Context context)
publishUnformattedback to summary
private void publishUnformatted(String event)
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