[dynamic control] add TraceSamplingRateValidator - #3076
Open
jackshirazi wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new trace sampling validator intended to parse ratio-shaped configurations (e.g., {"trace-sampling":{"ratio":0.75}}) as part of the dynamic-control trace sampling policy evolution.
Changes:
- Introduces
TraceSamplingRateValidator(ratio keyword) as anAbstractTraceSamplingValidatorspecialization. - Adds
TraceSamplingRateValidatorTestcovering flat numeric,ratiokeyword JSON, and key-value parsing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRateValidator.java | New validator that parses ratio keyword / numeric values into TraceSamplingRatePolicy. |
| dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRateValidatorTest.java | New unit tests validating ratio parsing and rejection cases. |
Suppressed comments (1)
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRateValidator.java:33
- The log message uses "sampling-rate" terminology, but this validator is for the
trace-samplingpolicy type. Aligning the message with the actual policy type makes operational logs easier to interpret.
try {
return new TraceSamplingRatePolicy(ratio, sourceKind);
} catch (IllegalArgumentException e) {
logger.info("Invalid sampling-rate ratio '" + ratio + "' will be ignored: " + e.getMessage());
return null;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Description:
TraceSamplingRatePolicy is implemented to use ratio, a value between 0-1. While this is technically correct, the examples in the telemetry policy spec provide percentages, and it's clear that both ratios and percentages need to be supported. The cleanest way to do this is to provide two policies which share the same behaviour except for naming and value conversion. Implementation is best done by abstracting common behaviour and providing minimal implementations of concrete subclasses. This is the next step to achieve that.
Existing Issue(s):
#2868
Testing:
Included
Documentation:
To be added
Outstanding items:
Expected set of PRs:
also #2868