Class ParentBasedSampler
- java.lang.Object
-
- io.opentelemetry.sdk.trace.samplers.ParentBasedSampler
-
- All Implemented Interfaces:
Sampler
@Immutable final class ParentBasedSampler extends java.lang.Object implements Sampler
A Sampler that uses the sampled flag of the parent Span, if present. If the span has no parent, this Sampler will use the "root" sampler that it is built with. See documentation on theParentBasedSamplerBuilder
methods for the details on the various configurable options.
-
-
Field Summary
Fields Modifier and Type Field Description private Sampler
localParentNotSampled
private Sampler
localParentSampled
private Sampler
remoteParentNotSampled
private Sampler
remoteParentSampled
private Sampler
root
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.lang.String
getDescription()
Returns the description of thisSampler
.int
hashCode()
SamplingResult
shouldSample(Context parentContext, java.lang.String traceId, java.lang.String name, SpanKind spanKind, Attributes attributes, java.util.List<LinkData> parentLinks)
Called duringSpan
creation to make a sampling samplingResult.java.lang.String
toString()
-
-
-
Field Detail
-
root
private final Sampler root
-
remoteParentSampled
private final Sampler remoteParentSampled
-
remoteParentNotSampled
private final Sampler remoteParentNotSampled
-
localParentSampled
private final Sampler localParentSampled
-
localParentNotSampled
private final Sampler localParentNotSampled
-
-
Method Detail
-
shouldSample
public SamplingResult shouldSample(Context parentContext, java.lang.String traceId, java.lang.String name, SpanKind spanKind, Attributes attributes, java.util.List<LinkData> parentLinks)
Description copied from interface:Sampler
Called duringSpan
creation to make a sampling samplingResult.- Specified by:
shouldSample
in interfaceSampler
- Parameters:
parentContext
- the parent span'sSpanContext
. This can beSpanContext.INVALID
if this is a root span.traceId
- theTraceId
for the newSpan
. This will be identical to that in the parentContext, unless this is a root span.name
- the name of the newSpan
.spanKind
- theSpanKind
of theSpan
.attributes
-Attributes
associated with the span.parentLinks
- the parentLinks associated with the newSpan
.- Returns:
- sampling samplingResult whether span should be sampled or not.
-
getDescription
public java.lang.String getDescription()
Description copied from interface:Sampler
Returns the description of thisSampler
. This may be displayed on debug pages or in the logs.Example: "TraceIdRatioBased{0.000100}"
- Specified by:
getDescription
in interfaceSampler
- Returns:
- the description of this
Sampler
.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(@Nullable java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-