Package io.opencensus.trace
Class SpanContext
java.lang.Object
io.opencensus.trace.SpanContext
A class that represents a span context. A span context contains the state that must propagate to
child
Span
s and across process boundaries. It contains the identifiers (a trace_id
and span_id
) associated with the Span
and a set of options
.- Since:
- 0.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SpanContext
The invalidSpanContext
.private final SpanId
private final TraceId
private final TraceOptions
private final Tracestate
private static final Tracestate
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
SpanContext
(TraceId traceId, SpanId spanId, TraceOptions traceOptions, Tracestate tracestate) -
Method Summary
Modifier and TypeMethodDescriptionstatic SpanContext
create
(TraceId traceId, SpanId spanId, TraceOptions traceOptions) Deprecated.static SpanContext
create
(TraceId traceId, SpanId spanId, TraceOptions traceOptions, Tracestate tracestate) Creates a newSpanContext
with the given identifiers and options.boolean
Returns the span identifier associated with thisSpanContext
.Returns the trace identifier associated with thisSpanContext
.Returns theTraceOptions
associated with thisSpanContext
.Returns theTracestate
associated with thisSpanContext
.int
hashCode()
boolean
isValid()
Returns true if thisSpanContext
is valid.toString()
-
Field Details
-
TRACESTATE_DEFAULT
-
traceId
-
spanId
-
traceOptions
-
tracestate
-
INVALID
The invalidSpanContext
.- Since:
- 0.5
-
-
Constructor Details
-
SpanContext
private SpanContext(TraceId traceId, SpanId spanId, TraceOptions traceOptions, Tracestate tracestate)
-
-
Method Details
-
create
@Deprecated public static SpanContext create(TraceId traceId, SpanId spanId, TraceOptions traceOptions) Deprecated.Creates a newSpanContext
with the given identifiers and options.- Parameters:
traceId
- the trace identifier of the span context.spanId
- the span identifier of the span context.traceOptions
- the trace options for the span context.- Returns:
- a new
SpanContext
with the given identifiers and options.
-
create
public static SpanContext create(TraceId traceId, SpanId spanId, TraceOptions traceOptions, Tracestate tracestate) Creates a newSpanContext
with the given identifiers and options.- Parameters:
traceId
- the trace identifier of the span context.spanId
- the span identifier of the span context.traceOptions
- the trace options for the span context.tracestate
- the trace state for the span context.- Returns:
- a new
SpanContext
with the given identifiers and options. - Since:
- 0.16
-
getTraceId
Returns the trace identifier associated with thisSpanContext
.- Returns:
- the trace identifier associated with this
SpanContext
. - Since:
- 0.5
-
getSpanId
Returns the span identifier associated with thisSpanContext
.- Returns:
- the span identifier associated with this
SpanContext
. - Since:
- 0.5
-
getTraceOptions
Returns theTraceOptions
associated with thisSpanContext
.- Returns:
- the
TraceOptions
associated with thisSpanContext
. - Since:
- 0.5
-
getTracestate
Returns theTracestate
associated with thisSpanContext
.- Returns:
- the
Tracestate
associated with thisSpanContext
. - Since:
- 0.5
-
isValid
public boolean isValid()Returns true if thisSpanContext
is valid.- Returns:
- true if this
SpanContext
is valid. - Since:
- 0.5
-
equals
-
hashCode
public int hashCode() -
toString
-
create(TraceId, SpanId, TraceOptions, Tracestate)
.