Package brave.sampler
Class Sampler
- java.lang.Object
-
- brave.sampler.Sampler
-
- Direct Known Subclasses:
BoundarySampler
,CountingSampler
,RateLimitingSampler
public abstract class Sampler extends Object
Sampler is responsible for deciding if a particular trace should be "sampled", i.e. whether the overhead of tracing will occur and/or if a trace will be reported to the collection tier.Zipkin v1 uses before-the-fact sampling. This means that the decision to keep or drop the trace is made before any work is measured, or annotations are added. As such, the input parameter to zipkin v1 samplers is the trace ID (lower 64-bits under the assumption all bits are random).
The instrumentation sampling decision happens once, at the root of the trace, and is propagated downstream. For this reason, the algorithm needn't be consistent based on trace ID.
-
-
Field Summary
Fields Modifier and Type Field Description static Sampler
ALWAYS_SAMPLE
static Sampler
NEVER_SAMPLE
-
Constructor Summary
Constructors Constructor Description Sampler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Sampler
create(float probability)
Returns a sampler, given a probability expressed as a percentage.abstract boolean
isSampled(long traceId)
Returns true if the trace ID should be measured.
-
-
-
Method Detail
-
isSampled
public abstract boolean isSampled(long traceId)
Returns true if the trace ID should be measured.- Parameters:
traceId
- The trace ID to be decided on, can be ignored
-
create
public static Sampler create(float probability)
Returns a sampler, given a probability expressed as a percentage.The sampler returned is good for low volumes of traffic (<100K requests), as it is precise. If you have high volumes of traffic, consider
BoundarySampler
.- Parameters:
probability
- probability a trace will be sampled. minimum is 0.01, or 1% of traces
-
-