Package io.opencensus.trace
Class SpanContext
- java.lang.Object
-
- io.opencensus.trace.SpanContext
-
@Immutable public final class SpanContext extends java.lang.ObjectA class that represents a span context. A span context contains the state that must propagate to childSpans and across process boundaries. It contains the identifiers (atrace_idandspan_id) associated with theSpanand a set ofoptions.- Since:
- 0.5
-
-
Field Summary
Fields Modifier and Type Field Description static SpanContextINVALIDThe invalidSpanContext.private SpanIdspanIdprivate TraceIdtraceIdprivate TraceOptionstraceOptionsprivate Tracestatetracestateprivate static TracestateTRACESTATE_DEFAULT
-
Constructor Summary
Constructors Modifier Constructor Description privateSpanContext(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 SpanContextcreate(TraceId traceId, SpanId spanId, TraceOptions traceOptions)Deprecated.static SpanContextcreate(TraceId traceId, SpanId spanId, TraceOptions traceOptions, Tracestate tracestate)Creates a newSpanContextwith the given identifiers and options.booleanequals(java.lang.Object obj)SpanIdgetSpanId()Returns the span identifier associated with thisSpanContext.TraceIdgetTraceId()Returns the trace identifier associated with thisSpanContext.TraceOptionsgetTraceOptions()Returns theTraceOptionsassociated with thisSpanContext.TracestategetTracestate()Returns theTracestateassociated with thisSpanContext.inthashCode()booleanisValid()Returns true if thisSpanContextis valid.java.lang.StringtoString()
-
-
-
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 newSpanContextwith 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
SpanContextwith the given identifiers and options.
-
create
public static SpanContext create(TraceId traceId, SpanId spanId, TraceOptions traceOptions, Tracestate tracestate)
Creates a newSpanContextwith 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
SpanContextwith 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 theTraceOptionsassociated with thisSpanContext.- Returns:
- the
TraceOptionsassociated with thisSpanContext. - Since:
- 0.5
-
getTracestate
public Tracestate getTracestate()
Returns theTracestateassociated with thisSpanContext.- Returns:
- the
Tracestateassociated with thisSpanContext. - Since:
- 0.5
-
isValid
public boolean isValid()
Returns true if thisSpanContextis valid.- Returns:
- true if this
SpanContextis valid. - Since:
- 0.5
-
equals
public boolean equals(@Nullable java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-