Skip to content

ComposableRuleBasedSampler configuration #341

@anuraaga

Description

@anuraaga

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 match
  • attribute_pattern: takes an attribute key and regex pattern and performs a regex match
  • span_kind: takes a span kind enum name and performs an exact match
  • is_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions