public class SpanContextImpl
extends java.lang.Object
implements io.opentracing.SpanContext
SpanContext. Keeps information about span id, trace
id and span parent id. Sampling flag is not included in the moment as it's not explicitly defined
by the opentracing API.| Constructor and Description |
|---|
SpanContextImpl(long id,
long traceId,
long parentId,
java.lang.String referenceType,
java.util.Map<java.lang.String,java.lang.String> baggage)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>> |
baggageItems() |
static SpanContextImpl |
build()
Builds new
SpanContextImpl with new trace context and no baggage. |
static SpanContextImpl |
build(java.util.Map<java.lang.String,java.lang.String> baggage)
Builds new
SpanContextImpl with new trace context and given baggage. |
static SpanContextImpl |
build(SpanContextImpl parent,
java.lang.String referenceType,
java.util.Map<java.lang.String,java.lang.String> baggage)
Builds new
SpanContextImpl as a child of given parent context. |
static SpanContextImpl |
buildExtractedContext(long passedId,
long passedTraceId,
java.util.Map<java.lang.String,java.lang.String> passedBaggage)
This method is used when building context that is extracted from the propagation (like HTTP
headers).
|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getBaggageItem(java.lang.String key)
Gets baggage item.
|
long |
getId()
Gets
id. |
long |
getParentId()
Gets
parentId. |
java.lang.String |
getReferenceType()
Returns reference type to the parent if the one is set.
|
long |
getTraceId()
Gets
traceId. |
int |
hashCode() |
void |
setBaggageItem(java.lang.String key,
java.lang.String value)
Sets baggage item.
|
java.lang.String |
toString() |
public SpanContextImpl(long id,
long traceId,
long parentId,
java.lang.String referenceType,
java.util.Map<java.lang.String,java.lang.String> baggage)
id - Unique ID of the span.traceId - ID of the trace that span belongs to.parentId - ID of the span's parent.referenceType - Reference to the parent.baggage - Additional baggagepublic static SpanContextImpl build(SpanContextImpl parent, java.lang.String referenceType, java.util.Map<java.lang.String,java.lang.String> baggage)
SpanContextImpl as a child of given parent context. If parent context is
null then build(Map) will be used and new trace context will be
created.
Passed baggage will be the baggage of this span context.
parent - Context that will be use to determine to which trace/parent new context belongs.
Can be null to denote that the new trace context should be created.referenceType - Reference type to the parent context.baggage - Context baggage.SpanContextImpl. Never null.public static SpanContextImpl build(java.util.Map<java.lang.String,java.lang.String> baggage)
SpanContextImpl with new trace context and given baggage.baggage - Context baggage.SpanContextImpl. Never null.public static SpanContextImpl build()
SpanContextImpl with new trace context and no baggage.SpanContextImpl. Never null.public static SpanContextImpl buildExtractedContext(long passedId, long passedTraceId, java.util.Map<java.lang.String,java.lang.String> passedBaggage)
passedId - calling span idpassedTraceId - calling span trace idpassedBaggage - passage traveling alongpublic java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>> baggageItems()
baggageItems in interface io.opentracing.SpanContextpublic void setBaggageItem(java.lang.String key,
java.lang.String value)
key - keyvalue - valuepublic java.lang.String getBaggageItem(java.lang.String key)
key - keynull if the one does not exist.public java.lang.String getReferenceType()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object