- java.lang.Object
-
- brave.sampler.Sampler
-
- brave.sampler.CountingSampler
-
public final class CountingSampler extends Sampler
This sampler is appropriate for low-traffic instrumentation (ex servers that each receive <100K requests), or those who do not provision random trace ids. It is not appropriate for collectors as the sampling decision isn't idempotent (consistent based on trace id).Implementation
This initializes a random bitset of size 100 (corresponding to 1% granularity). This means that it is accurate in units of 100 traces. At runtime, this loops through the bitset, returning the value according to a counter.
-
-
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 Samplercreate(float probability)booleanisSampled(long traceIdIgnored)loops over the pre-canned decisions, resetting to zero when it gets to the end.java.lang.StringtoString()
-
-
-
Method Detail
-
create
public static Sampler create(float probability)
- Parameters:
probability- probability a request will result in a new trace. 0 means never sample, 1 means always sample. Minimum probability is 0.01, or 1% of traces
-
isSampled
public boolean isSampled(long traceIdIgnored)
loops over the pre-canned decisions, resetting to zero when it gets to the end.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-