[dynamic control] Add json and keyvalue parsing and mapping#2655
Open
jackshirazi wants to merge 1 commit intoopen-telemetry:mainfrom
Open
[dynamic control] Add json and keyvalue parsing and mapping#2655jackshirazi wants to merge 1 commit intoopen-telemetry:mainfrom
jackshirazi wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
SourceFormatenum to dispatch parsing by configured source format (JSON vs key/value). - Introduced
SourceWrapperplus concreteJsonSourceWrapperandKeyValueSourceWrapperimplementations. - 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. |
...trol/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/KeyValueSourceWrapper.java
Show resolved
Hide resolved
.../src/test/java/io/opentelemetry/contrib/dynamic/policy/source/KeyValueSourceWrapperTest.java
Show resolved
Hide resolved
LikeTheSalad
approved these changes
Feb 26, 2026
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:
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