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
matcha rule. If all calls to a java method should have the same sample rate, considerDeclarativeSamplerinstead.- Since:
- 4.4
- See Also:
Matcher
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParameterizedSampler.Builder<P>static classParameterizedSampler.Rule<P>Deprecated.Since 5.8, useParameterizedSampler.Builder.putRule(Matcher, Sampler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 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()SamplingFlagssample(P parameters)Deprecated.Since 5.8, usetrySample(Object)BooleantrySample(P parameters)Returns an overriding sampling decision for a new trace.
-
-
-
Method Detail
-
newBuilder
public static <P> ParameterizedSampler.Builder<P> newBuilder()
- Since:
- 5.8
-
trySample
@Nullable public Boolean trySample(P parameters)
Returns an overriding sampling decision for a new trace. Returning null is typically used to defer to thetrace ID sampler.- Specified by:
trySamplein 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 public SamplingFlags sample(@Nullable P parameters)
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
-
-