Interface SamplingResult
@Immutable
public interface SamplingResult
Sampling result returned by
Sampler.shouldSample(Context, String, String, SpanKind, Attributes, List)
.-
Method Summary
Modifier and TypeMethodDescriptionstatic SamplingResult
create
(SamplingDecision decision) static SamplingResult
create
(SamplingDecision decision, io.opentelemetry.api.common.Attributes attributes) static SamplingResult
drop()
Returns aSamplingResult
corresponding toSamplingDecision.DROP
with no attributes.io.opentelemetry.api.common.Attributes
Return 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.TraceState
getUpdatedTraceState
(io.opentelemetry.api.trace.TraceState parentTraceState) Return an optionally-updatedTraceState
, based on the parent TraceState.static SamplingResult
Returns aSamplingResult
corresponding toSamplingDecision.RECORD_AND_SAMPLE
with no attributes.static SamplingResult
Returns aSamplingResult
corresponding toSamplingDecision.RECORD_ONLY
with no attributes.
-
Method Details
-
create
Returns aSamplingResult
with no attributes andgetDecision()
returningdecision
.This is meant for use by custom
Sampler
implementations.Use
create(SamplingDecision, Attributes)
if you need attributes.- Parameters:
decision
- The decision made on the span.- Returns:
- A
SamplingResult
with empty attributes and the provideddecision
.
-
create
static SamplingResult create(SamplingDecision decision, io.opentelemetry.api.common.Attributes attributes) Returns aSamplingResult
with the givenattributes
andgetDecision()
returningdecision
.This is meant for use by custom
Sampler
implementations.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
SamplingResult
with the attributes equivalent toattributes
and the provideddecision
.
-
recordAndSample
Returns aSamplingResult
corresponding toSamplingDecision.RECORD_AND_SAMPLE
with no attributes.This is meant for use by custom
Sampler
implementations and is equivalent to callingSamplingResult.create(SamplingDecision.RECORD_AND_SAMPLE)
.- Returns:
- A "record and sample"
SamplingResult
with empty attributes.
-
recordOnly
Returns aSamplingResult
corresponding toSamplingDecision.RECORD_ONLY
with no attributes.This is meant for use by custom
Sampler
implementations and is equivalent to callingSamplingResult.create(SamplingDecision.RECORD_ONLY)
.- Returns:
- A "record only"
SamplingResult
with empty attributes.
-
drop
Returns aSamplingResult
corresponding toSamplingDecision.DROP
with no attributes.This is meant for use by custom
Sampler
implementations and is equivalent to callingSamplingResult.create(SamplingDecision.DROP)
.- Returns:
- A "drop"
SamplingResult
with 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_ONLY
orSamplingDecision.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 sameTraceState
that 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 theSpanContext
parameter on theSampler.shouldSample(Context, String, String, SpanKind, Attributes, List)
call.
-