public interface Span
Span
represents the OpenTracing specification's Span contract.Scope
,
ScopeManager
,
Tracer.SpanBuilder.start()
,
Tracer.SpanBuilder#startActive()
Modifier and Type | Method and Description |
---|---|
SpanContext |
context()
Retrieve the associated SpanContext.
|
void |
finish()
Sets the end timestamp to now and records the span.
|
void |
finish(long finishMicros)
Sets an explicit end timestamp and records the span.
|
String |
getBaggageItem(String key) |
Span |
log(long timestampMicroseconds,
Map<String,?> fields)
Like log(Map<String, Object>), but with an explicit timestamp.
|
Span |
log(long timestampMicroseconds,
String event)
Record an event at a specific timestamp.
|
Span |
log(Map<String,?> fields)
Log key:value pairs to the Span with the current walltime timestamp.
|
Span |
log(String event)
Record an event at the current walltime timestamp.
|
Span |
setBaggageItem(String key,
String value)
Sets a baggage item in the Span (and its SpanContext) as a key/value pair.
|
Span |
setOperationName(String operationName)
Sets the string name for the logical operation this span represents.
|
Span |
setTag(String key,
boolean value)
Same as
setTag(String, String) , but for boolean values. |
Span |
setTag(String key,
Number value)
Same as
setTag(String, String) , but for numeric values. |
Span |
setTag(String key,
String value)
Set a key:value tag on the Span.
|
SpanContext context()
Span setTag(String key, boolean value)
setTag(String, String)
, but for boolean values.Span setTag(String key, Number value)
setTag(String, String)
, but for numeric values.Span log(Map<String,?> fields)
CAUTIONARY 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());
fields
- key:value log fields. Tracer implementations should support String, numeric, and boolean values;
some may also support arbitrary Objects.log(String)
Span log(long timestampMicroseconds, Map<String,?> fields)
CAUTIONARY NOTE: not all Tracer implementations support key:value log fields end-to-end. Caveat emptor.
timestampMicroseconds
- 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.log(long, String)
Span log(String event)
span.log(Collections.singletonMap("event", event));
event
- the event value; often a stable identifier for a moment in the Span lifecycleSpan log(long timestampMicroseconds, String event)
span.log(timestampMicroseconds, Collections.singletonMap("event", event));
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 lifecycleSpan setBaggageItem(String key, String value)
String getBaggageItem(String key)
Span setOperationName(String operationName)
void finish()
With the exception of calls to context()
, this should be the last call made to the span instance.
Future calls to finish()
are defined as noops, and future calls to methods other than context()
lead to undefined behavior.
context()
void finish(long finishMicros)
With the exception of calls to Span.context(), this should be the last call made to the span instance, and to do otherwise leads to undefined behavior.
finishMicros
- an explicit finish time, in microseconds since the epochcontext()
Copyright © 2016–2018 OpenTracing. All rights reserved.