Skip to content

[dynamic control] Use composable samplers and add sampler initialization#2752

Merged
jaydeluca merged 3 commits intoopen-telemetry:mainfrom
jackshirazi:policy22
Apr 9, 2026
Merged

[dynamic control] Use composable samplers and add sampler initialization#2752
jaydeluca merged 3 commits intoopen-telemetry:mainfrom
jackshirazi:policy22

Conversation

@jackshirazi
Copy link
Copy Markdown
Contributor

Description:

Add initialization for TraceSamplingRatePolicy, and use the latest spec sampler (the expected future SDK default) of parent based trace ratio sampler. Note that the TraceSamplingRatePolicy installs an opinionated sampler. There can be other policies (in the future) which can be more generic, it's up to the user to choose which policy implementation they want to configure when creating the policy pipeline

Existing Issue(s):

#2546

Testing:

Added

Documentation:

Added

Outstanding items:

Wiring up the policy pipeline:

  • Generic: message -> provider -> policy -> policy handler -> implementer
  • eg change sampling rate message -> OpampPolicyProvider -> TraceSamplingRatePolicy -> PolicyStore -> TraceSamplingRatePolicyImplementer

Steps needed for the wiring:

  • providers reading policies, eg OpampPolicyProvider, FilePolicyProvider, etc
    • DONE: OpampPolicyProvider
  • implementers applying policies, eg TraceSamplingRatePolicyImplementer
    • DONE: TraceSamplingRatePolicyImplementer
  • policy structures (eg TraceSamplingRatePolicy) that the provider converts messages into
    • DONE: TraceSamplingRatePolicy
  • registering config to policy structures (eg "trace_sampling_rate_policy" registered to TraceSamplingRatePolicy)
  • initializing policy classes (eg TraceSamplingRatePolicy needs to install a custom sampler)
    • TraceSamplingRatePolicy initialization in this PR
  • activate configured providers (eg start OpampPolicyprovider reading from it's source)
  • register implementers for policies (eg a new TraceSamplingRatePolicy is applied by a TraceSamplingRatePolicyImplementer)
  • link the provider to processing policies and applying implementers

Copilot AI review requested due to automatic review settings April 9, 2026 10:46
@jackshirazi jackshirazi requested a review from a team as a code owner April 9, 2026 10:46
@github-actions github-actions bot requested a review from LikeTheSalad April 9, 2026 10:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds runtime sampler wiring for the dynamic-control trace-sampling policy, switching sampler creation to the newer composable/parent-threshold approach.

Changes:

  • Add TraceSamplingRatePolicy.initialize(...) to install a delegating sampler via autoconfigure.
  • Introduce TraceSamplingRatePolicy.createSampler(probability) using composable/composite samplers.
  • Update TraceSamplingRatePolicyImplementer to use createSampler(...) and log applied updates; add unit tests and incubator dependency.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRatePolicy.java Adds initialization hook + new sampler factory using composable samplers.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRatePolicyImplementer.java Uses the new sampler factory (and logs) when applying policy changes.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRatePolicyTest.java Adds unit coverage for validation, initialization, equality/hashCode, and sampler factory behavior.
dynamic-control/build.gradle.kts Adds incubator dependency required by the new sampler implementation.

@jaydeluca jaydeluca added this pull request to the merge queue Apr 9, 2026
Merged via the queue into open-telemetry:main with commit 48dd6b4 Apr 9, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants