Top Description Inners Fields Methods
io.micrometer.tracing

public Interface CurrentTraceContext

Imports
io.micrometer.common.lang.Nullable, java.io.Closeable, java.util.concurrent.Callable, .Executor, .ExecutorService

This API was heavily influenced by Brave. Parts of its documentation were taken directly from Brave.

This makes a given span the current span by placing it in scope (usually but not always a thread local scope).

Authors
OpenZipkin Brave Authors, Marcin Grzejszczak
Since
1.0.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
CurrentTraceContext.Scope

Scope of a span.

Field Summary

Modifier and TypeField and Description
public static final CurrentTraceContext
NOOP

A noop implementation.

Method Summary

Modifier and TypeMethod and Description
public TraceContext

Returns:

current TraceContext or null if not set.
context
()

public CurrentTraceContext.Scope

Returns:

the scope with the span set
maybeScope
(TraceContext
span to place into scope or null to clear the scope
context
)

Like newScope(TraceContext), except returns a noop scope if the given context is already in scope.

public CurrentTraceContext.Scope

Returns:

the scope with the span set
newScope
(TraceContext
span to place into scope or null to clear the scope
context
)

Sets the current span in scope until the returned object is closed.

public <
task return type
C
>
Callable<C>

Returns:

wrapped task
wrap
(Callable<C>
task to wrap
task
)

Wraps a task in a trace representation.

public Runnable

Returns:

wrapped task
wrap
(Runnable
task to wrap
task
)

Wraps a task in a trace representation.

public Executor

Returns:

wrapped executor
wrap
(Executor
executor to wrap
delegate
)

Wraps an executor in a trace representation.

public ExecutorService

Returns:

wrapped executor service
wrap
(ExecutorService
executor service to wrap
delegate
)

Wraps an executor service in a trace representation.

Field Detail

NOOPback to summary
public static final CurrentTraceContext NOOP

A noop implementation.

Method Detail

contextback to summary
public TraceContext context()
Returns:TraceContext

current TraceContext or null if not set.

Annotations
@Nullable
maybeScopeback to summary
public CurrentTraceContext.Scope maybeScope(TraceContext context)

Like newScope(TraceContext), except returns a noop scope if the given context is already in scope.

Parameters
context:TraceContext

span to place into scope or null to clear the scope

Returns:CurrentTraceContext.Scope

the scope with the span set

newScopeback to summary
public CurrentTraceContext.Scope newScope(TraceContext context)

Sets the current span in scope until the returned object is closed. It is a programming error to drop or never close the result. Using try-with-resources is preferred for this reason.

Parameters
context:TraceContext

span to place into scope or null to clear the scope

Returns:CurrentTraceContext.Scope

the scope with the span set

wrapback to summary
public <C> Callable<C> wrap(Callable<C> task)

Wraps a task in a trace representation.

Parameters
<C>
task return type
task:Callable<C>

task to wrap

Returns:Callable<C>

wrapped task

wrapback to summary
public Runnable wrap(Runnable task)

Wraps a task in a trace representation.

Parameters
task:Runnable

task to wrap

Returns:Runnable

wrapped task

wrapback to summary
public Executor wrap(Executor delegate)

Wraps an executor in a trace representation.

Parameters
delegate:Executor

executor to wrap

Returns:Executor

wrapped executor

wrapback to summary
public ExecutorService wrap(ExecutorService delegate)

Wraps an executor service in a trace representation.

Parameters
delegate:ExecutorService

executor service to wrap

Returns:ExecutorService

wrapped executor service

io.micrometer.tracing back to summary

public Interface CurrentTraceContext.Scope

extends Closeable
Known Direct Implementers
io.micrometer.tracing.handler.RevertingScope

Scope of a span. Needs to be closed so that resources are let go (e.g. MDC is cleared).

Field Summary

Modifier and TypeField and Description
public static final CurrentTraceContext.Scope
NOOP

A noop implementation.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Redeclares java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

Field Detail

NOOPback to summary
public static final CurrentTraceContext.Scope NOOP

A noop implementation.

Method Detail

closeback to summary
public void close()

Redeclares java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override