public interface Span extends Closeable
Spans are created by the Tracer.buildSpan(java.lang.String)
interface.
Modifier and Type | Method and Description |
---|---|
void |
close() |
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(long timestampMicroseconds,
String eventName,
Object payload)
Deprecated.
use
log(Map) like this
span.log(timestampMicroseconds, Map.of("event", "timeout"))
or
span.log(timestampMicroseconds, Map.of("event", "exception", "payload", stackTrace)) |
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 |
log(String eventName,
Object payload)
Deprecated.
use
log(Map) like this
span.log(Map.of("event", "timeout"))
or
span.log(timestampMicroseconds, Map.of("event", "exception", "payload", stackTrace)) |
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()
void finish()
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.
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()
void close()
close
in interface AutoCloseable
close
in interface Closeable
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<String, Object>()
.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)
Span log(String eventName, Object payload)
log(Map)
like this
span.log(Map.of("event", "timeout"))
or
span.log(timestampMicroseconds, Map.of("event", "exception", "payload", stackTrace))
Copyright © 2016–2017 OpenTracing. All rights reserved.