@FunctionalInterface public interface Sampler<T>
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.
| Modifier and Type | Method and Description |
|---|---|
static <T> Sampler<T> |
always()
Returns a sampler that will always return
true. |
boolean |
isSampled(T object)
Returns
true if a request should be recorded. |
static <T> Sampler<T> |
never()
Returns a sampler that will always return
false. |
static <T> Sampler<T> |
of(String specification)
Returns a
Sampler that is configured as specified in the given specification string. |
static <T> Sampler<T> |
random(double probability)
Returns a probabilistic sampler which samples at the specified
probability
between 0.0 and 1.0. |
static <T> Sampler<T> |
rateLimited(int samplesPerSecond)
Deprecated.
Use
rateLimiting(int). |
static <T> Sampler<T> |
rateLimiting(int samplesPerSecond)
Returns a rate-limiting sampler which rate-limits up to the specified
samplesPerSecond. |
static <T> Sampler<T> random(double probability)
probability
between 0.0 and 1.0.probability - the probability expressed as a floating point number
between 0.0 and 1.0.static <T> Sampler<T> rateLimiting(int samplesPerSecond)
samplesPerSecond.samplesPerSecond - an integer between 0 and @Deprecated static <T> Sampler<T> rateLimited(int samplesPerSecond)
rateLimiting(int).samplesPerSecond.samplesPerSecond - an integer between 0 and static <T> Sampler<T> always()
true.static <T> Sampler<T> never()
false.static <T> Sampler<T> of(String specification)
Sampler that is configured as specified in the given specification string.
The specification string must be formatted in one of the following formats:
"always"
Sampler that always samples."never"
Sampler that never samples."random=<probability>" where probability is a floating point number
between 0.0 and 1.0
Sampler which samples at the specified probability."random=0.05" to sample at 5% probability"rate-limit=<samples_per_sec>" where samples_per_sec is a non-negative integer
Sampler which rate-limits up to the specified
samples per second."rate-limit=10" to sample 10 samples per second at mostboolean isSampled(T object)
true if a request should be recorded.object - the object to be decided on, can be ignoredCopyright © 2020 LeanCloud. All rights reserved.