Skip to content

[dynamic control] Move away from JSON requirement#2652

Open
jackshirazi wants to merge 3 commits intoopen-telemetry:mainfrom
jackshirazi:policy7
Open

[dynamic control] Move away from JSON requirement#2652
jackshirazi wants to merge 3 commits intoopen-telemetry:mainfrom
jackshirazi:policy7

Conversation

@jackshirazi
Copy link
Contributor

Description:

The Telemetry Policy OTEP has moved away from a specific JSON requirement to a non-specific data structure. First step in moving to this updated spec is to migrate away from JSON in the telemetry policy. As a by product, it's cleaner in many ways

Existing Issue(s):

#2546

Testing:

Tests updated

Documentation:

Documentation has been changed accordingly but the module documentation is the same as it's the same architecture

Outstanding items:

Although this is cleaner, it means there will be an additional mapping infrastructure needed to map custom structures into providers

@jackshirazi jackshirazi requested a review from a team as a code owner February 24, 2026 14:47
Copilot AI review requested due to automatic review settings February 24, 2026 14:47
@jackshirazi jackshirazi changed the title Move away from JSON requirement [dynamic control] Move away from JSON requirement Feb 24, 2026
Copy link
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

This pull request refactors the telemetry policy implementation to move away from JSON-based specifications to a type-specific subclass approach, aligning with the updated Telemetry Policy OTEP. The change replaces the generic TelemetryPolicy class that previously held a JsonNode spec field with a cleaner architecture where specific policy types extend TelemetryPolicy.

Changes:

  • Removes JSON dependency from TelemetryPolicy core class, eliminating the spec field
  • Introduces TraceSamplingRatePolicy as a concrete subclass with strong typing
  • Updates validation and implementation logic to work with typed policies instead of JSON structures

Reviewed changes

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

Show a summary per file
File Description
TelemetryPolicy.java Removes JsonNode spec field and getSpec() method; simplifies to type-only base class
TraceSamplingRatePolicy.java New concrete subclass holding probability value with constructor validation
TraceSamplingValidator.java Updated to return TraceSamplingRatePolicy instances instead of generic policies with JSON specs
TraceSamplingRatePolicyImplementer.java Refactored to use instanceof checks and direct probability access instead of JSON parsing
TraceSamplingValidatorTest.java Updated assertions to check for TraceSamplingRatePolicy instances and use getProbability()
TraceSamplingRatePolicyImplementerTest.java Replaced JSON-based test helpers with direct TraceSamplingRatePolicy instantiation
LinePerPolicyFileProviderTest.java Updated mock validator to use single-argument TelemetryPolicy constructor

Copy link
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

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

*
* @see io.opentelemetry.contrib.dynamic.policy
*/
public class TelemetryPolicy {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker, but I'm curious if it makes sense to turn this into an interface to make it more flexible/easier to extend? I don't have a specific use case in mind where more flexibility would be needed; it's just that the rules around dynamic support are changing so often that it might be useful to have such flexibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now its useful as a concrete class for resetting to default. I've considered having it abstract or as an interface but it seems most useful at the moment as a concrete class. My aim is to have a working extension that supports sampling rate changes, then add further functionality and see how it changes as needed. Since this is all experimental, letting it evolve as needed rather than trying to anticipate the end state, is the preferred way to go (I think)

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.

3 participants