Skip to content

[dynamic control] Add json and keyvalue parsing and mapping#2655

Open
jackshirazi wants to merge 1 commit intoopen-telemetry:mainfrom
jackshirazi:policy8
Open

[dynamic control] Add json and keyvalue parsing and mapping#2655
jackshirazi wants to merge 1 commit intoopen-telemetry:mainfrom
jackshirazi:policy8

Conversation

@jackshirazi
Copy link
Contributor

@jackshirazi jackshirazi commented Feb 25, 2026

Description:

The Telemetry Policy OTEP has moved away from a specific JSON requirement to a non-specific data structure. This step in moving to this updated spec is to add a more generic parsing mechanism including both json and key-value parsing. Note this is not fully generic mapping, but this is sufficient for flat key-value policies (which is potentially all that is needed in the future, and definitely all that is needed for now)

Existing Issue(s):

#2546

Testing:

Tests updated

Documentation:

Documentation has been added in the classes

Outstanding items:

there are changes needed to use this new parsing/mapping infrastructure, that will be applied in a future PR after this and #2652 are merged

Copilot AI review requested due to automatic review settings February 25, 2026 15:27
@jackshirazi jackshirazi requested a review from a team as a code owner February 25, 2026 15:27
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 PR extends the dynamic-control module’s telemetry policy “source” layer with a format-dispatching parser that can normalize inputs from either JSON or a flat key/value representation, aligning with the updated Telemetry Policy OTEP’s move away from a JSON-only intermediate representation.

Changes:

  • Added SourceFormat enum to dispatch parsing by configured source format (JSON vs key/value).
  • Introduced SourceWrapper plus concrete JsonSourceWrapper and KeyValueSourceWrapper implementations.
  • Added unit tests covering parsing behavior, invalid-shape handling, immutability, and null rejection.

Reviewed changes

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

Show a summary per file
File Description
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/SourceWrapper.java New interface to represent a parsed source payload alongside its format.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/SourceFormat.java New format enum that centralizes format selection and delegates parsing.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/KeyValueSourceWrapper.java New key/value parser and wrapper type for flat policies.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/JsonSourceWrapper.java New JSON parser and wrapper type for supported JSON shapes.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/source/SourceFormatTest.java Tests for format config values and parsing delegation/contract.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/source/KeyValueSourceWrapperTest.java Tests for key/value parsing behavior and edge cases.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/source/JsonSourceWrapperTest.java Tests for supported JSON shapes, immutability, and invalid input handling.

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