Skip to content

[dynamic control] add TraceSamplingRateValidator - #3076

Open
jackshirazi wants to merge 1 commit into
open-telemetry:mainfrom
jackshirazi:policy-phase2-29
Open

[dynamic control] add TraceSamplingRateValidator#3076
jackshirazi wants to merge 1 commit into
open-telemetry:mainfrom
jackshirazi:policy-phase2-29

Conversation

@jackshirazi

Copy link
Copy Markdown
Contributor

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

Copilot AI lite review requested due to automatic review settings August 27, 2026 20:57
@jackshirazi
jackshirazi requested a review from a team as a code owner August 27, 2026 20:57
@github-actions
github-actions Bot requested a review from LikeTheSalad August 27, 2026 20:58

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

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 an AbstractTraceSamplingValidator specialization.
  • Adds TraceSamplingRateValidatorTest covering flat numeric, ratio keyword 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-sampling policy 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.

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