Skip to content

Tail-based sampling with policies evaluated with first match mechanism #36795

Open
@stollero

Description

@stollero

Component(s)

processor/tailsampling

Is your feature request related to a problem? Please describe.

The tail-based sampler currently evaluates all policies before making a decision. This makes it quite complicate to create a more complex policy set. E.g. set a default samplerate for all that do not match the previous policies.

I want to avoid the following pattern:

Define a rule:

  # filter by route
  name: route-name-policy,
  type: string_attribute,
  string_attribute:
    {
      key: http.route,
      values: [/v1/name/.+],
      enabled_regex_matching: true,
    },

Define the rule once more, but invert the match to get all other:

    {
      # invert match - apply to all routes except the ones specified
      name: route-name-policy,
      type: string_attribute,
      string_attribute:
        {
          key: http.route,
          values: [/v1/name/.+],
          enabled_regex_matching: true,
          invert_match: true,
        },
    },

I want to add a flag that allows you to specify a set of policies that will determine whether a trace should be sampled or not. The policies are evaluated in order, and the first policy that matches will be used to determine the sample rate.

Describe the solution you'd like

I imagine a new flag, like first_policy_match, for the processor that changes the behaviour:

processors:
  tail_sampling:
    first_policy_match: true
    decision_cache:
      sampled_cache_size: 100_000
      non_sampled_cache_size: 100_000
    policies:
         ....

Describe alternatives you've considered

Using the current mechanism, but copying policies to add the invert_match flag. Which can be prone to errors and makes it hard to read.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions