public interface ScopeManager
ScopeManager interface abstracts both the activation of Span instances via
activate(Span) and access to an active Span
via activeSpan().Scope,
Tracer.scopeManager()| Modifier and Type | Method and Description |
|---|---|
Scope |
activate(Span span)
Set the specified
Span as the active instance for the current
context (usually a thread). |
Span |
activeSpan()
Return the currently active
Span. |
Scope activate(Span span)
Span as the active instance for the current
context (usually a thread).
The returned Scope represents the active state for the span.
Once its active period is due, Scope.close() ought to be called.
To ease this operation, Scope supports try-with-resources.
Observe the span will not be automatically finished when Scope.close()
is called.
The corresponding Span can be accessed at any time through activeSpan().
Usage:
Span span = tracer.buildSpan("...").start();
try (Scope scope = tracer.scopeManager().activate(span)) {
span.setTag("...", "...");
...
} catch (Exception e) {
span.log(...);
} finally {
// Optionally finish the Span if the operation it represents
// is logically completed at this point.
span.finish();
}
span - the Span that should become the activeSpan()Scope instance to control the end of the active period for the Span. It is a
programming error to neglect to call Scope.close() on the returned instance.Span activeSpan()
Span.
Because both #active() and activeSpan() reference the current
active state, they both will be either null or non-null.
active span, or null if none could be found.Copyright © 2016–2019 OpenTracing. All rights reserved.