Package brave.sampler
Class BoundarySampler
- java.lang.Object
-
- brave.sampler.Sampler
-
- brave.sampler.BoundarySampler
-
public final class BoundarySampler extends Sampler
This sampler is appropriate for high-traffic instrumentation (ex edge web servers that each receive >100K requests) who provision random trace ids, and make the sampling decision only once. It defends against nodes in the cluster selecting exactly the same ids.Implementation
This uses modulo 10000 arithmetic, which allows a minimum probability of 0.01%. Trace id collision was noticed in practice in the Twitter front-end cluster. A random salt is here to defend against nodes in the same cluster sampling exactly the same subset of trace ids. The goal was full 64-bit coverage of trace IDs on multi-host deployments.
Based on https://github.com/twitter/finagle/blob/b6b1d0414fa24ed0c8bb5112985a4e9c9bcd3c9e/finagle-zipkin-core/src/main/scala/com/twitter/finagle/zipkin/core/Sampler.scala#L68
-
-
Field Summary
-
Fields inherited from class brave.sampler.Sampler
ALWAYS_SAMPLE, NEVER_SAMPLE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Sampler
create(float probability)
boolean
isSampled(long traceId)
Returns true whenabs(traceId) <= boundary
String
toString()
-
-
-
Method Detail
-
create
public static Sampler create(float probability)
- Parameters:
probability
- 0 means never sample, 1 means always sample. Otherwise minimum probability is 0.0001, or 0.01% of traces
-
isSampled
public boolean isSampled(long traceId)
Returns true whenabs(traceId) <= boundary
-
-