public final class TraceContext extends SamplingFlags
Particularly, this includes trace identifiers and sampled state.
The implementation was originally com.github.kristofa.brave.SpanId
, which was a
port of com.twitter.finagle.tracing.TraceId
. Unlike these mentioned, this type does not
expose a single binary representation. That's because propagation forms can now vary.
Modifier and Type | Class | Description |
---|---|---|
static class |
TraceContext.Builder |
|
static interface |
TraceContext.Extractor<C> |
Used to join an incoming trace.
|
static interface |
TraceContext.Injector<C> |
Used to send the trace context downstream.
|
DEBUG, EMPTY, NOT_SAMPLED, SAMPLED
Modifier and Type | Method | Description |
---|---|---|
boolean |
debug() |
True is a request to store this span even if it overrides sampling policy.
|
boolean |
equals(Object o) |
|
List<Object> |
extra() |
Returns a list of additional data propagated through this trace.
|
int |
hashCode() |
|
static TraceContext.Builder |
newBuilder() |
|
Long |
parentId() |
The parent's
spanId or null if this the root span in a trace. |
long |
parentIdAsLong() |
Like
parentId() except returns a primitive where zero implies absent. |
Boolean |
sampled() |
Should we sample this request or not? True means sample, false means don't, null means we defer
decision to someone further down in the stack.
|
boolean |
shared() |
Deprecated.
it is unnecessary overhead to propagate this property
|
long |
spanId() |
Unique 8-byte identifier of this span within a trace.
|
TraceContext.Builder |
toBuilder() |
|
String |
toString() |
Returns
$traceId/$spanId |
long |
traceId() |
Unique 8-byte identifier for a trace, set on all spans within it.
|
long |
traceIdHigh() |
When non-zero, the trace containing this span uses 128-bit trace identifiers.
|
String |
traceIdString() |
Returns the hex representation of the span's trace ID
|
public static TraceContext.Builder newBuilder()
public long traceIdHigh()
public long traceId()
@Nullable public final Long parentId()
spanId
or null if this the root span in a trace.parentIdAsLong()
public long parentIdAsLong()
parentId()
except returns a primitive where zero implies absent.
Using this method will avoid allocation, so is encouraged when copying data.
@Nullable public Boolean sampled()
sampled
in class SamplingFlags
public boolean debug()
debug
in class SamplingFlags
public long spanId()
@Deprecated public final boolean shared()
public List<Object> extra()
The contents are intentionally opaque, deferring to Propagation to define. An example implementation could be storing a class containing a correlation value, which is extracted from incoming requests and injected as-is onto outgoing requests.
Implementations are responsible for scoping any data stored here. This can be performed when
Propagation.Factory.decorate(TraceContext)
is called.
public TraceContext.Builder toBuilder()
public String traceIdString()
Copyright © 2018 OpenZipkin. All rights reserved.