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 theParentBasedSamplerBuildermethods for the details on the various configurable options.
-
-
Field Summary
Fields Modifier and Type Field Description private SamplerlocalParentNotSampledprivate SamplerlocalParentSampledprivate SamplerremoteParentNotSampledprivate SamplerremoteParentSampledprivate Samplerroot
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.StringgetDescription()Returns the description of thisSampler.inthashCode()SamplingResultshouldSample(Context parentContext, java.lang.String traceId, java.lang.String name, SpanKind spanKind, Attributes attributes, java.util.List<LinkData> parentLinks)Called duringSpancreation to make a sampling samplingResult.java.lang.StringtoString()
-
-
-
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: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- theSpanKindof 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 java.lang.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.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(@Nullable java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-