Class ParentBasedSampler
- java.lang.Object
-
- io.opentelemetry.sdk.trace.samplers.ParentBasedSampler
-
- All Implemented Interfaces:
Sampler
@Immutable public class ParentBasedSampler extends 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 theParentBasedSampler.Builder
methods for the details on the various configurable options.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ParentBasedSampler.Builder
A builder for creating ParentBased sampler instances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
String
getDescription()
Returns the description of thisSampler
.int
hashCode()
SamplingResult
shouldSample(io.opentelemetry.context.Context parentContext, String traceId, String name, io.opentelemetry.api.trace.Span.Kind spanKind, io.opentelemetry.api.common.Attributes attributes, List<SpanData.Link> parentLinks)
Called duringSpan
creation to make a sampling samplingResult.String
toString()
-
-
-
Method Detail
-
shouldSample
public SamplingResult shouldSample(io.opentelemetry.context.Context parentContext, String traceId, String name, io.opentelemetry.api.trace.Span.Kind spanKind, io.opentelemetry.api.common.Attributes attributes, List<SpanData.Link> 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
- theSpan.Kind
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 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
.
-
-