Top Description Inners Methods
io.micrometer.tracing.handler

public Interface TracingObservationHandler<T extends Observation.Context>

extends ObservationHandler<T extends Observation.Context>
Known Direct Implementers
io.micrometer.tracing.handler.DefaultTracingObservationHandler, io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler, io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler
Type Parameters
<T>
type of handler context
Imports
io.micrometer.common.KeyValue, io.micrometer.common.lang.NonNull, .Nullable, io.micrometer.common.util.StringUtils, io.micrometer.observation.Observation, .Observation.Event, .ObservationHandler, .ObservationView, io.micrometer.tracing.CurrentTraceContext, .Span, .TraceContext, .Tracer, io.micrometer.tracing.internal.SpanNameUtil, java.util.Collections, .Map, java.util.concurrent.ConcurrentHashMap, .TimeUnit

Marker interface for tracing handlers.
Author
Marcin Grzejszczak
Since
1.0.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Method Summary

Modifier and TypeMethod and Description
public default void
endSpan(T
context
context
,
Span
span to end
span
)

Ends span and clears resources.

public default Span

Returns:

parent span or null when there's none
getParentSpan
(Observation.ContextView context)

Get the current span from parent if applicable.

public default Span

Returns:

span or exception
getRequiredSpan
(T
context
context
)

Returns the span from the context or throws an exception if it's not there.

public default String

Returns:

name for the span
getSpanName
(T
handler context
context
)

Get the span name.

public Tracer

Returns:

tracer
getTracer
()

Returns the Tracer.

public default TracingObservationHandler.TracingContext

Returns:

tracing context
getTracingContext
(T context)

Get the current tracing context and updates the context if it's missing.

public default void
onError(T context)

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

Reacts to an error during an Observation.
public default void
onEvent(Observation.Event
the Observation.Event that was signaled
event
,
T context)

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

Reacts to arbitrary Observation.
public default void
onScopeClosed(T
recording with context containing scope
context
)

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

Cleans the scope present in the context.
public default void
onScopeOpened(T
recording with context containing scope
context
)

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

Puts the span in scope.
public default void
onScopeReset(T context)

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

Reacts to resetting of scopes.
public default void
setMaybeScopeOnTracingContext(TracingObservationHandler.TracingContext
handler's tracing context
tracingContext
,
Span
span, whose context will be used to create a new scope. Span can be null.
newSpan
)

Creates or reuses an existing CurrentTraceContext.Scope given the Span.

public default boolean
supportsContext(Observation.Context context)

Implements io.micrometer.observation.ObservationHandler.supportsContext.

Tells the registry whether this handler should be applied for a given Observation.
public default void
tagSpan(T
handler context
context
,
Span
span to tag
span
)

Tags the span.

Inherited from io.micrometer.observation.ObservationHandler:
onStartonStop

Method Detail

endSpanback to summary
public default void endSpan(T context, Span span)

Ends span and clears resources.

Parameters
context:T

context

span:Span

span to end

getParentSpanback to summary
public default Span getParentSpan(Observation.ContextView context)

Get the current span from parent if applicable.

Parameters
context:Observation.ContextView

a Observation.ContextView

Returns:Span

parent span or null when there's none

Annotations
@Nullable
getRequiredSpanback to summary
public default Span getRequiredSpan(T context)

Returns the span from the context or throws an exception if it's not there.

Parameters
context:T

context

Returns:Span

span or exception

getSpanNameback to summary
public default String getSpanName(T context)

Get the span name.

Parameters
context:T

handler context

Returns:String

name for the span

getTracerback to summary
public Tracer getTracer()

Returns the Tracer.

Returns:Tracer

tracer

getTracingContextback to summary
public default TracingObservationHandler.TracingContext getTracingContext(T context)

Get the current tracing context and updates the context if it's missing.

Parameters
context:T

a Observation.Context

Returns:TracingObservationHandler.TracingContext

tracing context

Annotations
@NonNull
onErrorback to summary
public default void onError(T context)

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

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

Reacts to an error during an Observation.

Parameters
context:T

an Observation.Context

Annotations
@Override
onEventback to summary
public default void onEvent(Observation.Event event, T 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:T

an Observation.Context

Annotations
@Override
onScopeClosedback to summary
public default void onScopeClosed(T context)

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

Cleans the scope present in the context.

Parameters
context:T

recording with context containing scope

Annotations
@Override
onScopeOpenedback to summary
public default void onScopeOpened(T context)

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

Puts the span in scope.

Parameters
context:T

recording with context containing scope

Annotations
@Override
onScopeResetback to summary
public default void onScopeReset(T 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:T

an Observation.Context

Annotations
@Override
setMaybeScopeOnTracingContextback to summary
public default void setMaybeScopeOnTracingContext(TracingObservationHandler.TracingContext tracingContext, Span newSpan)

Creates or reuses an existing CurrentTraceContext.Scope given the Span. Span can be null in which a scope that resets current scope but remembers the previously present value will be created.

Parameters
tracingContext:TracingObservationHandler.TracingContext

handler's tracing context

newSpan:Span

span, whose context will be used to create a new scope. Span can be null.

Since
1.0.4
supportsContextback to summary
public default 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
tagSpanback to summary
public default void tagSpan(T context, Span span)

Tags the span.

Parameters
context:T

handler context

span:Span

span to tag

io.micrometer.tracing.handler back to summary

public Class TracingObservationHandler.TracingContext

extends Object
implements AutoCloseable
Class Inheritance
  • java.lang.Object
  • io.micrometer.tracing.handler.TracingObservationHandler.TracingContext
All Implemented Interfaces
java.lang.AutoCloseable

Basic tracing context.
Author
Marcin Grzejszczak
Since
1.0.0

Field Summary

Modifier and TypeField and Description
private Map<Thread, CurrentTraceContext.Scope>
private Span

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.
public Map<String, String>

Returns:

baggage attached to the span
getBaggage
()

Deprecated scheduled for removal in 1.5.0
Returns the baggage corresponding to this span.
public CurrentTraceContext.Scope

Returns:

scope of the span
getScope
()

Returns the scope of the span.

public Span

Returns:

span
getSpan
()

Returns the span.

public void
setBaggage(Map<String, String>
baggage to set
baggage
)

Deprecated scheduled for removal in 1.5.0
Sets the baggage
public void
setScope(CurrentTraceContext.Scope
scope to set
scope
)

Sets the current trace context scope.

public void
setSpan(Span
span to set
span
)

Sets the span.

public void
setSpanAndScope(Span
span to set
span
,
CurrentTraceContext.Scope
scope to set
scope
)

Convenience method to set both span and scope.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

scopesback to summary
private Map<Thread, CurrentTraceContext.Scope> scopes
spanback to summary
private Span span

Constructor Detail

TracingContextback to summary
public TracingContext()

Method Detail

closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
getBaggageback to summary
public Map<String, String> getBaggage()

Deprecated

scheduled for removal in 1.5.0

Returns the baggage corresponding to this span.

Returns:Map<String, String>

baggage attached to the span

Annotations
@Deprecated
getScopeback to summary
public CurrentTraceContext.Scope getScope()

Returns the scope of the span.

Returns:CurrentTraceContext.Scope

scope of the span

getSpanback to summary
public Span getSpan()

Returns the span.

Returns:Span

span

setBaggageback to summary
public void setBaggage(Map<String, String> baggage)

Deprecated

scheduled for removal in 1.5.0

Sets the baggage

Parameters
baggage:Map<String, String>

baggage to set

Annotations
@Deprecated
setScopeback to summary
public void setScope(CurrentTraceContext.Scope scope)

Sets the current trace context scope.

Parameters
scope:CurrentTraceContext.Scope

scope to set

setSpanback to summary
public void setSpan(Span span)

Sets the span.

Parameters
span:Span

span to set

setSpanAndScopeback to summary
public void setSpanAndScope(Span span, CurrentTraceContext.Scope scope)

Convenience method to set both span and scope.

Parameters
span:Span

span to set

scope:CurrentTraceContext.Scope

scope to set

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
traceContextFromSpanback to summary
private String traceContextFromSpan()