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.Buildermethods for the details on the various configurable options.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParentBasedSampler.BuilderA builder for creating ParentBased sampler instances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)StringgetDescription()Returns the description of thisSampler.inthashCode()SamplingResultshouldSample(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 duringSpancreation to make a sampling samplingResult.StringtoString()
-
-
-
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:SamplerCalled duringSpancreation to make a sampling samplingResult.- Specified by:
shouldSamplein interfaceSampler- Parameters:
parentContext- the parent span'sSpanContext. This can beSpanContext.INVALIDif this is a root span.traceId- theTraceIdfor 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.Kindof theSpan.attributes-Attributesassociated 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:SamplerReturns the description of thisSampler. This may be displayed on debug pages or in the logs.Example: "TraceIdRatioBased{0.000100}"
- Specified by:
getDescriptionin interfaceSampler- Returns:
- the description of this
Sampler.
-
-