public final class SpanId extends Object
This implementation is biased towards a fixed-length binary serialization format that doesn't
have a way to represent an absent parent (root span). In this serialized form, a root span is
when all three ids are the same. Alternatively, you can use nullableParentId()
.
Particularly, this includes sampled state, and a portable binary representation. The
implementation is a port of com.twitter.finagle.tracing.TraceId
.
Modifier and Type | Class and Description |
---|---|
static class |
SpanId.Builder |
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_DEBUG |
static int |
FLAG_IS_ROOT
When set, we can ignore the value of the
parentId |
static int |
FLAG_SAMPLED |
static int |
FLAG_SAMPLING_SET
When set, we can interpret
FLAG_SAMPLED as a set value. |
long |
flags
Raw flags encoded in
bytes() |
long |
parentId
|
long |
spanId
Unique 8-byte identifier of this span within a trace.
|
long |
traceId
Unique 8-byte identifier for a trace, set on all spans within it.
|
Constructor and Description |
---|
SpanId(long traceId,
long parentId,
long spanId,
long flags)
Deprecated.
Please use
SpanId.Builder |
Modifier and Type | Method and Description |
---|---|
static SpanId.Builder |
builder() |
byte[] |
bytes()
Serializes this into a big-endian byte array
|
static SpanId |
create(long traceId,
long spanId,
Long parentSpanId)
Deprecated.
Please use
SpanId.Builder |
boolean |
debug()
True is a request to store this span even if it overrides sampling policy.
|
boolean |
equals(Object o) |
static SpanId |
fromBytes(byte[] bytes)
Deserializes this from a big-endian byte array
|
Long |
getParentSpanId()
Deprecated.
|
long |
getSpanId()
Deprecated.
use
spanId |
long |
getTraceId()
Deprecated.
use
traceId |
int |
hashCode() |
Long |
nullableParentId()
Returns null when this is a root span.
|
boolean |
root()
Returns true if this is the root span.
|
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.
|
SpanId.Builder |
toBuilder() |
Span |
toSpan()
Preferred way to create spans, as it properly deals with the parent id
|
String |
toString()
Returns
$traceId.$spanId<:$parentId |
public static final int FLAG_DEBUG
public static final int FLAG_SAMPLING_SET
FLAG_SAMPLED
as a set value.public static final int FLAG_SAMPLED
public static final int FLAG_IS_ROOT
parentId
While many zipkin systems re-use a trace id as the root span id, we know that some don't. With this flag, we can tell for sure if the span is root as opposed to the convention trace id == span id == parent id.
public final long traceId
public final long parentId
public final long spanId
A span is uniquely identified in storage by (traceId, #id
).
public final long flags
bytes()
@Deprecated public SpanId(long traceId, long parentId, long spanId, long flags)
SpanId.Builder
@Deprecated public static SpanId create(long traceId, long spanId, @Nullable Long parentSpanId)
SpanId.Builder
traceId
- Trace Id.spanId
- Span Id.parentSpanId
- Nullable parent span id.public static SpanId fromBytes(byte[] bytes)
public static SpanId.Builder builder()
@Deprecated public long getTraceId()
traceId
@Deprecated public long getSpanId()
spanId
@Deprecated @Nullable public Long getParentSpanId()
nullableParentId()
null
.public final boolean root()
public final boolean debug()
sampled()
.@Nullable public final Boolean sampled()
public byte[] bytes()
public SpanId.Builder toBuilder()
public String toString()
$traceId.$spanId<:$parentId
public Span toSpan()
Copyright © 2016. All rights reserved.