Package io.opencensus.trace
Class Sampler
- java.lang.Object
-
- io.opencensus.trace.Sampler
-
- Direct Known Subclasses:
AlwaysSampleSampler
,NeverSampleSampler
,ProbabilitySampler
public abstract class Sampler extends java.lang.Object
Sampler is used to make decisions onSpan
sampling.- Since:
- 0.5
-
-
Constructor Summary
Constructors Constructor Description Sampler()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract java.lang.String
getDescription()
Returns the description of thisSampler
.abstract boolean
shouldSample(SpanContext parentContext, java.lang.Boolean hasRemoteParent, TraceId traceId, SpanId spanId, java.lang.String name, java.util.List<Span> parentLinks)
Called duringSpan
creation to make a sampling decision.
-
-
-
Method Detail
-
shouldSample
public abstract boolean shouldSample(@Nullable SpanContext parentContext, @Nullable java.lang.Boolean hasRemoteParent, TraceId traceId, SpanId spanId, java.lang.String name, java.util.List<Span> parentLinks)
Called duringSpan
creation to make a sampling decision.- Parameters:
parentContext
- the parent span'sSpanContext
.null
if this is a root span.hasRemoteParent
-true
if the parentSpan
is remote.null
if this is a root span.traceId
- theTraceId
for the newSpan
. This will be identical to that in the parentContext, unless this is a root span.spanId
- theSpanId
for the newSpan
.name
- the name of the newSpan
.parentLinks
- the parentLinks associated with the newSpan
.- Returns:
true
if theSpan
is sampled.- Since:
- 0.5
-
getDescription
public abstract java.lang.String getDescription()
Returns the description of thisSampler
. This may be displayed on debug pages or in the logs.Example: "ProbabilitySampler{0.000100}"
- Returns:
- the description of this
Sampler
. - Since:
- 0.6
-
-