-
Notifications
You must be signed in to change notification settings - Fork 29
Description
There is a new rule-based sampler in the spec
https://opentelemetry.io/docs/specs/otel/trace/sdk/#composablerulebased
Unlike every other sampler, this one needs special care in configuration since we can't "just model args as JSON" - one of the args is an arbitrary predicate function. So we need to define what types of predicates should be supported specifically by declarative configuration. For starters, I suggest the following
attribute_value: takes an attribute key and value and performs an exact matchattribute_pattern: takes an attribute key and regex pattern and performs a regex matchspan_kind: takes a span kind enum name and performs an exact matchis_root: no parameters, matches if the span is a root span.
We can allow all of these to be defined at the same time to perform an AND composition (it should probably be an error to have both attribute specs though). If no predicate is specified, it is catch-all - in practice, most rule sets will almost always have this in the end because the default for a non-match is to drop.
The rule would contain the predicates, and sampler, with the latter being identical to the current Sampler schema.
Example
sampler:
rule_based:
rules:
- attribute_value:
key: http.route
value: /health
sampler:
always_off:
- span_kind: CLIENT
is_root: true
sampler:
always_off:
- sampler: # The default sampler, parent-based always-on
Let me know how that sounds. /cc @jack-berg