Skip to content

Add support for composite samplers in declarative config#5201

Open
xrmx wants to merge 4 commits into
open-telemetry:mainfrom
xrmx:declarative-config-rulebasedsampler
Open

Add support for composite samplers in declarative config#5201
xrmx wants to merge 4 commits into
open-telemetry:mainfrom
xrmx:declarative-config-rulebasedsampler

Conversation

@xrmx
Copy link
Copy Markdown
Contributor

@xrmx xrmx commented May 12, 2026

Description

This adds support for the in development composite samplers to declarative config support.

Refs #3631

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • tox

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@xrmx xrmx requested a review from a team as a code owner May 12, 2026 13:23
if config.trace_id_ratio_based is not None:
ratio = config.trace_id_ratio_based.ratio
return TraceIdRatioBased(ratio if ratio is not None else 1.0)
if config.composite_development is not None:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if this is still in development this is not gated under an option to filter stable only components because with declarative config the enablement of experimental stuff is explicit by the user

"""An exact match of an attribute value"""

def __init__(self, key: str, value: AnyValue):
logging.warning(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a predicate I had around when implemented the rule based sampler, does not make much sense to keep around since we have one that implements a superset of its features

return f"{self.key}={self.value}"


class AlwaysMatchPredicate:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if these are not spec'ed in the SDK specification I've added these predicates near the rule based sampler. It looked more natural to have them here instead of in sdk configuration side for discoverability if you are not using declarative config. I think Java does not do that though.

@emdneto
Copy link
Copy Markdown
Member

emdneto commented May 12, 2026

Thanks for the PR!

Just a heads-up: we no longer update CHANGELOG.md directly. The changelog is now generated from changelog fragments using Towncrier.

Please add the appropriate changelog fragment for this change instead of editing CHANGELOG.md manually. You can find the instructions and expected format in CONTRIBUTING.md.

@xrmx xrmx force-pushed the declarative-config-rulebasedsampler branch from bbddc5a to 240b1e7 Compare May 13, 2026 09:07
@xrmx xrmx moved this to Ready for review in Python PR digest May 13, 2026
return (value,)


def _glob_matches(value: str, glob_pattern: str) -> bool:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use fnmatch here? Also, do we need to handle escaping and such?

@herin049
Copy link
Copy Markdown
Contributor

One small comment/question, but overall LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

4 participants