Interface SamplingResult
-
@Immutable public interface SamplingResultSampling result returned bySampler.shouldSample(Context, String, String, SpanKind, Attributes, List).
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static SamplingResultcreate(SamplingDecision decision)static SamplingResultcreate(SamplingDecision decision, io.opentelemetry.api.common.Attributes attributes)io.opentelemetry.api.common.AttributesgetAttributes()Return tags which will be attached to the span.SamplingDecisiongetDecision()Return decision on whether a span should be recorded, recorded and sampled or not recorded.default io.opentelemetry.api.trace.TraceStategetUpdatedTraceState(io.opentelemetry.api.trace.TraceState parentTraceState)Return an optionally-updatedTraceState, based on the parent TraceState.
-
-
-
Method Detail
-
create
static SamplingResult create(SamplingDecision decision)
Returns aSamplingResultwith no attributes andgetDecision()returningdecision.This is meant for use by custom
Samplerimplementations.Use
create(SamplingDecision, Attributes)if you need attributes.- Parameters:
decision- The decision made on the span.- Returns:
- A
SamplingResultwith empty attributes and the provideddecision.
-
create
static SamplingResult create(SamplingDecision decision, io.opentelemetry.api.common.Attributes attributes)
Returns aSamplingResultwith the givenattributesandgetDecision()returningdecision.This is meant for use by custom
Samplerimplementations.Using
create(SamplingDecision)instead of this method is slightly faster and shorter if you don't need attributes.- Parameters:
decision- The decision made on the span.attributes- The attributes to return fromgetAttributes(). A different object instance with the same elements may be returned.- Returns:
- A
SamplingResultwith the attributes equivalent toattributesand the provideddecision.
-
getDecision
SamplingDecision getDecision()
Return decision on whether a span should be recorded, recorded and sampled or not recorded.- Returns:
- sampling result.
-
getAttributes
io.opentelemetry.api.common.Attributes getAttributes()
Return tags which will be attached to the span.- Returns:
- attributes added to span. These attributes should be added to the span only when
the sampling decision is
SamplingDecision.RECORD_ONLYorSamplingDecision.RECORD_AND_SAMPLE.
-
getUpdatedTraceState
default io.opentelemetry.api.trace.TraceState getUpdatedTraceState(io.opentelemetry.api.trace.TraceState parentTraceState)
Return an optionally-updatedTraceState, based on the parent TraceState. This may return the sameTraceStatethat was provided originally, or an updated one.- Parameters:
parentTraceState- The TraceState from the parent span. Might be an empty TraceState, if there is no parent. This will be the same TraceState that was passed in via theSpanContextparameter on theSampler.shouldSample(Context, String, String, SpanKind, Attributes, List)call.
-
-