Package brave.sampler
Class ParameterizedSampler<P>
java.lang.Object
brave.sampler.ParameterizedSampler<P>
- Type Parameters:
P
- The type that encloses parameters associated with a sample rate. For example, this could be a pair of http and method.
- All Implemented Interfaces:
SamplerFunction<P>
public final class ParameterizedSampler<P> extends Object implements SamplerFunction<P>
This is an implementation of how to decide whether to trace a request using ordered rules. For
example, you could write rules to look at an HTTP method and path, or a RabbitMQ routing key and
queue name.
This looks at runtime parameters to see if they match
a rule.
If all calls to a java method should have the same sample rate, consider DeclarativeSampler
instead.
- Since:
- 4.4
- See Also:
Matcher
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ParameterizedSampler.Builder<P>
static class
ParameterizedSampler.Rule<P>
Deprecated.Since 5.8, useParameterizedSampler.Builder.putRule(Matcher, Sampler)
-
Method Summary
Modifier and Type Method Description static <P> ParameterizedSampler<P>
create(List<? extends ParameterizedSampler.Rule<P>> rules)
Deprecated.since 5.8, usenewBuilder()
static <P> ParameterizedSampler.Builder<P>
newBuilder()
SamplingFlags
sample(P parameters)
Deprecated.Since 5.8, usetrySample(Object)
Boolean
trySample(P parameters)
Returns an overriding sampling decision for a new trace.
-
Method Details
-
newBuilder
- Since:
- 5.8
-
trySample
Returns an overriding sampling decision for a new trace. Returning null is typically used to defer to thetrace ID sampler
.- Specified by:
trySample
in interfaceSamplerFunction<P>
- Parameters:
parameters
- parameter to evaluate for a sampling decision. null input results in a null result- Returns:
- true to sample a new trace or false to deny. Null defers the decision.
- Since:
- 5.8
-
sample
Deprecated.Since 5.8, usetrySample(Object)
- Since:
- 4.4
-
create
@Deprecated public static <P> ParameterizedSampler<P> create(List<? extends ParameterizedSampler.Rule<P>> rules)Deprecated.since 5.8, usenewBuilder()
- Since:
- 4.4
-