public class ActiveSpanShim extends Object implements ActiveSpan, SpanWrapper
ActiveSpan.Continuation| Modifier | Constructor and Description |
|---|---|
protected |
ActiveSpanShim(io.opentracing.Scope scope) |
| Modifier and Type | Method and Description |
|---|---|
ActiveSpan.Continuation |
capture()
"Capture" a new
ActiveSpan.Continuation associated with this ActiveSpan and Span, as well as any
3rd-party execution context of interest. |
void |
close()
A synonym for
ActiveSpan.deactivate() that can be used in try-with-resources blocks. |
SpanContext |
context()
Retrieve the associated SpanContext.
|
void |
deactivate()
Mark the end of the active period for the current thread and
ActiveSpan. |
boolean |
equals(Object obj) |
String |
getBaggageItem(String key) |
ActiveSpanShim |
log(long timestampMicros,
Map<String,?> fields)
Like log(Map<String, Object>), but with an explicit timestamp.
|
ActiveSpanShim |
log(long timestampMicroseconds,
String event)
Record an event at a specific timestamp.
|
ActiveSpanShim |
log(Map<String,?> fields)
Log key:value pairs to the Span with the current walltime timestamp.
|
ActiveSpanShim |
log(String event)
Record an event at the current walltime timestamp.
|
protected io.opentracing.Scope |
scope() |
ActiveSpanShim |
setBaggageItem(String key,
String value)
Sets a baggage item in the Span (and its SpanContext) as a key/value pair.
|
ActiveSpanShim |
setOperationName(String operationName)
Sets the string name for the logical operation this span represents.
|
ActiveSpanShim |
setTag(String key,
boolean value)
Same as
BaseSpan.setTag(String, String), but for boolean values. |
ActiveSpanShim |
setTag(String key,
Number value)
Same as
BaseSpan.setTag(String, String), but for numeric values. |
ActiveSpanShim |
setTag(String key,
String value)
Set a key:value tag on the Span.
|
io.opentracing.Span |
span() |
String |
toString() |
protected io.opentracing.Scope scope()
public io.opentracing.Span span()
span in interface SpanWrapperpublic void deactivate()
ActiveSpanActiveSpan. When the last
ActiveSpan is deactivated for a given Span, it is automatically Span.finish()ed.
NOTE: Calling ActiveSpan.deactivate() more than once on a single ActiveSpan instance leads to undefined
behavior.
deactivate in interface ActiveSpan{@link ActiveSpan}s are auto-closeable and may be used in try-with-resources blockspublic void close()
ActiveSpanActiveSpan.deactivate() that can be used in try-with-resources blocks.close in interface ActiveSpanclose in interface Closeableclose in interface AutoCloseablepublic ActiveSpan.Continuation capture()
ActiveSpanActiveSpan.Continuation associated with this ActiveSpan and Span, as well as any
3rd-party execution context of interest. The ActiveSpan.Continuation may be used as data in a closure or callback
function where the ActiveSpan may be resumed and reactivated.
IMPORTANT: the caller MUST ActiveSpan.Continuation.activate() and ActiveSpan.deactivate() the
returned ActiveSpan.Continuation or the associated Span will never automatically Span.finish().
That is, calling ActiveSpan.capture() increments a refcount that must be decremented somewhere else.
The associated Span will not Span.finish() while a ActiveSpan.Continuation is outstanding; in
this way, it provides a reference/pin just like an ActiveSpan does.
capture in interface ActiveSpanActiveSpan.Continuation to ActiveSpan.Continuation.activate() at the appropriate time.public SpanContext context()
BaseSpancontext in interface BaseSpan<ActiveSpan>public ActiveSpanShim setTag(String key, String value)
BaseSpansetTag in interface BaseSpan<ActiveSpan>public ActiveSpanShim setTag(String key, boolean value)
BaseSpanBaseSpan.setTag(String, String), but for boolean values.setTag in interface BaseSpan<ActiveSpan>public ActiveSpanShim setTag(String key, Number value)
BaseSpanBaseSpan.setTag(String, String), but for numeric values.setTag in interface BaseSpan<ActiveSpan>public final ActiveSpanShim log(Map<String,?> fields)
BaseSpanCAUTIONARY NOTE: not all Tracer implementations support key:value log fields end-to-end. Caveat emptor.
A contrived example (using Guava, which is not required):
span.log(
ImmutableMap.Builder()
.put("event", "soft error")
.put("type", "cache timeout")
.put("waited.millis", 1500)
.build());
log in interface BaseSpan<ActiveSpan>fields - key:value log fields. Tracer implementations should support String, numeric, and boolean values;
some may also support arbitrary Objects.BaseSpan.log(String)public final ActiveSpanShim log(long timestampMicros, Map<String,?> fields)
BaseSpanCAUTIONARY NOTE: not all Tracer implementations support key:value log fields end-to-end. Caveat emptor.
log in interface BaseSpan<ActiveSpan>timestampMicros - The explicit timestamp for the log record. Must be greater than or equal to the
Span's start timestamp.fields - key:value log fields. Tracer implementations should support String, numeric, and boolean values;
some may also support arbitrary Objects.BaseSpan.log(long, String)public ActiveSpanShim log(String event)
BaseSpan
span.log(Collections.singletonMap("event", event));
log in interface BaseSpan<ActiveSpan>event - the event value; often a stable identifier for a moment in the Span lifecyclepublic ActiveSpanShim log(long timestampMicroseconds, String event)
BaseSpan
span.log(timestampMicroseconds, Collections.singletonMap("event", event));
log in interface BaseSpan<ActiveSpan>timestampMicroseconds - The explicit timestamp for the log record. Must be greater than or equal to the
Span's start timestamp.event - the event value; often a stable identifier for a moment in the Span lifecyclepublic ActiveSpanShim setBaggageItem(String key, String value)
BaseSpansetBaggageItem in interface BaseSpan<ActiveSpan>public String getBaggageItem(String key)
getBaggageItem in interface BaseSpan<ActiveSpan>public ActiveSpanShim setOperationName(String operationName)
BaseSpansetOperationName in interface BaseSpan<ActiveSpan>Copyright © 2016–2018 OpenTracing. All rights reserved.