Interface SamplingResult
@Immutable
public interface SamplingResult
Sampling result returned by
Sampler.shouldSample(Context, String, String, SpanKind, Attributes, List).-
Method Summary
Modifier and TypeMethodDescriptionstatic SamplingResultcreate(SamplingDecision decision) static SamplingResultcreate(SamplingDecision decision, io.opentelemetry.api.common.Attributes attributes) static SamplingResultdrop()Returns aSamplingResultcorresponding toSamplingDecision.DROPwith no attributes.io.opentelemetry.api.common.AttributesReturn tags which will be attached to the span.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.static SamplingResultReturns aSamplingResultcorresponding toSamplingDecision.RECORD_AND_SAMPLEwith no attributes.static SamplingResultReturns aSamplingResultcorresponding toSamplingDecision.RECORD_ONLYwith no attributes.
-
Method Details
-
create
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.
-
recordAndSample
Returns aSamplingResultcorresponding toSamplingDecision.RECORD_AND_SAMPLEwith no attributes.This is meant for use by custom
Samplerimplementations and is equivalent to callingSamplingResult.create(SamplingDecision.RECORD_AND_SAMPLE).- Returns:
- A "record and sample"
SamplingResultwith empty attributes.
-
recordOnly
Returns aSamplingResultcorresponding toSamplingDecision.RECORD_ONLYwith no attributes.This is meant for use by custom
Samplerimplementations and is equivalent to callingSamplingResult.create(SamplingDecision.RECORD_ONLY).- Returns:
- A "record only"
SamplingResultwith empty attributes.
-
drop
Returns aSamplingResultcorresponding toSamplingDecision.DROPwith no attributes.This is meant for use by custom
Samplerimplementations and is equivalent to callingSamplingResult.create(SamplingDecision.DROP).- Returns:
- A "drop"
SamplingResultwith empty attributes.
-
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.
-