Interface SamplingResult
-
public interface SamplingResult
Sampling result returned bySampler.shouldSample(Context, String, String, Span.Kind, Attributes, List)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
SamplingResult.Decision
A decision on whether a span should be recorded, recorded and sampled or dropped.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static SamplingResult
create(SamplingResult.Decision decision)
static SamplingResult
create(SamplingResult.Decision decision, io.opentelemetry.api.common.Attributes attributes)
io.opentelemetry.api.common.Attributes
getAttributes()
Return tags which will be attached to the span.SamplingResult.Decision
getDecision()
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.
-
-
-
Method Detail
-
create
static SamplingResult create(SamplingResult.Decision decision)
Returns aSamplingResult
with no attributes andgetDecision()
returningdecision
.This is meant for use by custom
Sampler
implementations.Use
create(Decision, 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(SamplingResult.Decision 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(Decision)
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
.
-
getDecision
SamplingResult.Decision 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
SamplingResult.Decision.RECORD_ONLY
orSamplingResult.Decision.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, Span.Kind, Attributes, List)
call.
-
-