[dynamic-control] Add trace sampling-rate implementer#2634
Open
jackshirazi wants to merge 9 commits intoopen-telemetry:mainfrom
Open
[dynamic-control] Add trace sampling-rate implementer#2634jackshirazi wants to merge 9 commits intoopen-telemetry:mainfrom
jackshirazi wants to merge 9 commits intoopen-telemetry:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a trace sampling-rate policy implementer for the dynamic-control module, enabling runtime changes to trace sampling rates through the Telemetry Policy framework. This is part of a larger effort to implement experimental Telemetry Policy support (issue #2546) based on the draft OpenTelemetry specification.
Changes:
- Introduces the
PolicyImplementerinterface for applying validated telemetry policies to runtime components - Implements
TraceSamplingRatePolicyImplementerto dynamically update trace sampling rates via aDelegatingSampler - Adds comprehensive unit tests for the implementer covering various scenarios including null specs, probability application, policy filtering, and conflict resolution
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| PolicyImplementer.java | New interface defining the contract for policy implementers with clear documentation of responsibilities and lifecycle |
| TraceSamplingRatePolicyImplementer.java | Implementation that translates trace-sampling policies into sampler configuration changes using the OpenTelemetry SDK |
| TraceSamplingRatePolicyImplementerTest.java | Comprehensive unit tests covering core functionality including edge cases and policy precedence rules |
...rc/main/java/io/opentelemetry/contrib/dynamic/policy/TraceSamplingRatePolicyImplementer.java
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/contrib/dynamic/policy/TraceSamplingRatePolicyImplementer.java
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/contrib/dynamic/policy/TraceSamplingRatePolicyImplementer.java
Show resolved
Hide resolved
...est/java/io/opentelemetry/contrib/dynamic/policy/TraceSamplingRatePolicyImplementerTest.java
Outdated
Show resolved
Hide resolved
...est/java/io/opentelemetry/contrib/dynamic/policy/TraceSamplingRatePolicyImplementerTest.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/contrib/dynamic/policy/TraceSamplingRatePolicyImplementer.java
Show resolved
Hide resolved
…/policy/TraceSamplingRatePolicyImplementer.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/policy/TraceSamplingRatePolicyImplementerTest.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
LikeTheSalad
approved these changes
Feb 17, 2026
jaydeluca
approved these changes
Feb 23, 2026
| new TraceSamplingRatePolicyImplementer(delegatingSampler); | ||
|
|
||
| implementer.onPoliciesChanged( | ||
| Collections.singletonList(new TelemetryPolicy("trace-sampling", null))); |
Member
There was a problem hiding this comment.
could do a static import for all of these usages. we recently added this to spotless in instrumentation so i imagine we'll do something similar here soon too
Suggested change
| Collections.singletonList(new TelemetryPolicy("trace-sampling", null))); | |
| singletonList(new TelemetryPolicy("trace-sampling", null))); |
Contributor
Author
There was a problem hiding this comment.
good suggestion, thanks. done now
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per #2546
A basic trace sampling-rate implementer which simplistically applies changes to the sample rate
A full working implementation of the open-telemetry/opentelemetry-specification#4738 is here in this branch
Note the final dynamic-control sampling management needs to be more sophisticated, to dynamically handle route exclusion/inclusions as well as sampling rate and needs to use the recently added composable samplers (by default), but that's all for later addition