Package io.opencensus.trace
Class SpanContext
- java.lang.Object
-
- io.opencensus.trace.SpanContext
-
@Immutable public final class SpanContext extends java.lang.Object
A class that represents a span context. A span context contains the state that must propagate to childSpan
s and across process boundaries. It contains the identifiers (atrace_id
andspan_id
) associated with theSpan
and a set ofoptions
.- Since:
- 0.5
-
-
Field Summary
Fields Modifier and Type Field Description static SpanContext
INVALID
The invalidSpanContext
.private SpanId
spanId
private TraceId
traceId
private TraceOptions
traceOptions
private Tracestate
tracestate
private static Tracestate
TRACESTATE_DEFAULT
-
Constructor Summary
Constructors Modifier Constructor Description private
SpanContext(TraceId traceId, SpanId spanId, TraceOptions traceOptions, Tracestate tracestate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static 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
equals(java.lang.Object obj)
SpanId
getSpanId()
Returns the span identifier associated with thisSpanContext
.TraceId
getTraceId()
Returns the trace identifier associated with thisSpanContext
.TraceOptions
getTraceOptions()
Returns theTraceOptions
associated with thisSpanContext
.Tracestate
getTracestate()
Returns theTracestate
associated with thisSpanContext
.int
hashCode()
boolean
isValid()
Returns true if thisSpanContext
is valid.java.lang.String
toString()
-
-
-
Field Detail
-
TRACESTATE_DEFAULT
private static final Tracestate TRACESTATE_DEFAULT
-
traceId
private final TraceId traceId
-
spanId
private final SpanId spanId
-
traceOptions
private final TraceOptions traceOptions
-
tracestate
private final Tracestate tracestate
-
INVALID
public static final SpanContext INVALID
The invalidSpanContext
.- Since:
- 0.5
-
-
Constructor Detail
-
SpanContext
private SpanContext(TraceId traceId, SpanId spanId, TraceOptions traceOptions, Tracestate tracestate)
-
-
Method Detail
-
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
public TraceId getTraceId()
Returns the trace identifier associated with thisSpanContext
.- Returns:
- the trace identifier associated with this
SpanContext
. - Since:
- 0.5
-
getSpanId
public SpanId getSpanId()
Returns the span identifier associated with thisSpanContext
.- Returns:
- the span identifier associated with this
SpanContext
. - Since:
- 0.5
-
getTraceOptions
public TraceOptions getTraceOptions()
Returns theTraceOptions
associated with thisSpanContext
.- Returns:
- the
TraceOptions
associated with thisSpanContext
. - Since:
- 0.5
-
getTracestate
public Tracestate 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
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-