Package brave.propagation
Class TraceContextOrSamplingFlags
java.lang.Object
brave.propagation.TraceContextOrSamplingFlags
public final class TraceContextOrSamplingFlags extends Object
Union type that contains only one of trace context, trace ID context or sampling flags. This type
is designed for use with
Tracer.nextSpan(TraceContextOrSamplingFlags)
.
Users should not create instances of this, rather use TraceContext.Extractor
provided
by a Propagation
implementation such as Propagation.B3_STRING
.
Those implementing Propagation
should use the following advice:
- If you have the trace and span ID, use
create(TraceContext)
- If you have only a trace ID, use
create(TraceIdContext)
- Otherwise, use
create(SamplingFlags)
If your propagation implementation needs additional state, append it via TraceContextOrSamplingFlags.Builder.addExtra(Object)
.
This started as a port of com.github.kristofa.brave.TraceData
, which served the same
purpose.
- See Also:
TraceContext.Extractor
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TraceContextOrSamplingFlags.Builder
-
Field Summary
Fields Modifier and Type Field Description static TraceContextOrSamplingFlags
DEBUG
static TraceContextOrSamplingFlags
EMPTY
static TraceContextOrSamplingFlags
NOT_SAMPLED
static TraceContextOrSamplingFlags
SAMPLED
-
Method Summary
Modifier and Type Method Description TraceContext
context()
static TraceContextOrSamplingFlags
create(SamplingFlags flags)
static TraceContextOrSamplingFlags
create(TraceContext context)
static TraceContextOrSamplingFlags
create(TraceIdContext traceIdContext)
static TraceContextOrSamplingFlags
create(Boolean sampled, boolean debug)
boolean
equals(Object o)
List<Object>
extra()
Non-empty whencontext()
is null: A list of additional state extracted from the carrier.int
hashCode()
static TraceContextOrSamplingFlags.Builder
newBuilder()
Boolean
sampled()
ReturnsSamplingFlags.sampled()
, regardless of subtype.TraceContextOrSamplingFlags
sampled(boolean sampled)
TraceContextOrSamplingFlags
sampled(Boolean sampled)
Deprecated.do not use object variant..boolean
sampledLocal()
ReturnsSamplingFlags.sampledLocal()
}, regardless of subtype.SamplingFlags
samplingFlags()
TraceContextOrSamplingFlags.Builder
toBuilder()
String
toString()
TraceIdContext
traceIdContext()
-
Field Details
-
Method Details
-
newBuilder
-
sampled
ReturnsSamplingFlags.sampled()
, regardless of subtype. -
sampledLocal
public final boolean sampledLocal()ReturnsSamplingFlags.sampledLocal()
}, regardless of subtype. -
sampled
Deprecated.do not use object variant.. only set when you have a sampling decision -
sampled
-
context
-
traceIdContext
-
samplingFlags
-
extra
Non-empty whencontext()
is null: A list of additional state extracted from the carrier.- See Also:
TraceContext.extra()
-
toBuilder
-
toString
-
create
-
create
-
create
-
create
-
equals
-
hashCode
public int hashCode()
-