open-telemetry / open-telemetry/opentelemetry-java-contrib

Support 'and' in RuleBasedRoutingSampler (.drop)

Open
#1,896 3 comments 0 reactions 2 assignees View on GitHub

@jack-berg is already working on this.

Since May 19, 2025.

component:samplers enhancement
Dominant language
Java
Stars
269
Forks
196
Avg merge
2d 7h
Merged PRs (30d)
38

Description

Component(s)

samplers

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

Right now this sampler allows dropping based on a single attribute, like so:
RuleBasedRoutingSampler.builder(SpanKind.SERVER, fallback)
.drop(CODE_FUNCTION, "myAnnoyingMethod")
.build());

In some cases, we would want to drop on a combination of attributes.
E.g. "code.function" with "code.namespace" (from CodeAttributesExtractor).

As far as I can tell, this isn't possible with the current RuleBasedRoutingSampler.

Describe the solution you'd like

RuleBasedRoutingSampler allows dropping (or other rules/actions),
based on a set of attributes.

Hopefully some nice fluent API could be created, but I'd be happy with just a few overloaded (2arg, 4 args, 6 args),
so I can do:
blabla.drop(CODE_FUNCTION, "myAnnoyingMethod", CODE_NAMESPACE, "myAnnoyingClass")

Describe alternatives you've considered

Writing my own custom Sampler, which gets ugly fast.
Matching just one attribute, like code.function, and carefully making sure the same value is not used in another context.

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.