Skip to content

[dynamic control] only change the sampling rate if it has changed value#2957

Open
jackshirazi wants to merge 2 commits into
open-telemetry:mainfrom
jackshirazi:policy-phase2-10
Open

[dynamic control] only change the sampling rate if it has changed value#2957
jackshirazi wants to merge 2 commits into
open-telemetry:mainfrom
jackshirazi:policy-phase2-10

Conversation

@jackshirazi

Copy link
Copy Markdown
Contributor

Description:

The policy aggregator spec doesn't require already applied policy changes to be eliminated, it delegates that optimization to the implementation. I've added the optimization that if there is no effective change to the sampling rate, then no actual change is applied

Existing Issue(s):

#2868

Testing:

added

Documentation:

n/a

Outstanding items:

#2868

@jackshirazi jackshirazi requested a review from a team as a code owner July 1, 2026 15:09
Copilot AI review requested due to automatic review settings July 1, 2026 15:09
@github-actions github-actions Bot requested a review from LikeTheSalad July 1, 2026 15:12

Copilot AI left a comment

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.

Pull request overview

Optimizes the dynamic-control trace sampling policy application path by avoiding reapplying an equivalent sampling probability, reducing unnecessary sampler churn and log noise when policy updates repeat the same effective value.

Changes:

  • Update TraceSamplingRatePolicyImplementer to apply sampling probability changes via DelegatingSampler.setSamplingProbability(...) and only log when an effective change occurs.
  • Add probability tracking to DelegatingSampler to atomically skip repeated equivalent probability updates.
  • Add a unit test to verify that repeated equivalent probability updates do not cause repeated delegate changes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRatePolicyImplementer.java Applies sampling probability updates via a helper that only logs when the delegate actually changes.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/DelegatingSampler.java Tracks last-applied probability and adds setSamplingProbability to skip equivalent updates.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRatePolicyImplementerTest.java Adds coverage ensuring repeated equivalent probability updates only apply once.

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.

2 participants