[dynamic control] Add pipeline config initialization from declarative config or failover to file#2766
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds initialization of dynamic-control’s telemetry policy pipeline from OpenTelemetry declarative config (preferred) with fallback to file-based YAML/JSON config.
Changes:
- Add
PolicyInitConfigloaders for declarative config (telemetry_policy.sources) and declarative-first fallback helpers (including viaOpenTelemetry/ExtendedOpenTelemetry). - Add file-based loading from
otel.java.experimental.telemetry.policy.init.yaml/jsonwith YAML precedence and warning-on-failure behavior. - Add unit tests covering declarative vs file fallback selection and error cases.
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/registry/PolicyInitConfig.java | Implements declarative-first init config parsing and file fallback, plus reflective access to “general config” accessor. |
| dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/registry/PolicyInitConfigTest.java | Adds tests for YAML/JSON precedence, parse failures, and declarative-vs-file selection paths. |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/registry/json/JsonNodePolicyInitConfigParser.java:55
- JSON init-config parsing now trims/normalizes optional
location, but other string fields (kind,format,sourceKey,policyType) are still accepted with leading/trailing whitespace (and even whitespace-only, sincerequireTextonly checksisEmpty()). This can lead to hard-to-debug mismatches because mapping keys/policy types are used verbatim downstream. Consider trimming and validating non-blank inrequireText(returning the trimmed value), and applying the same normalization to mapping fields for consistency with declarative parsing.
JsonNode locationNode = objectNode.get("location");
String location =
locationNode != null && locationNode.isTextual()
? normalizeOptionalText(locationNode.asText())
: null;
JsonNode mappingsNode =
requireArray(objectNode.get("mappings"), "Each source must define a 'mappings' array.");
List<PolicySourceMappingConfig> mappings = new ArrayList<>();
LikeTheSalad
approved these changes
Apr 28, 2026
jaydeluca
reviewed
May 5, 2026
Although strictly speaking not a bug to have empty source mappings, it seems silly and most likely an error so agree it's good to catch it Co-authored-by: Jay DeLuca <[email protected]>
Co-authored-by: Jay DeLuca <[email protected]>
Co-authored-by: Jay DeLuca <[email protected]>
jaydeluca
approved these changes
May 7, 2026
jaydeluca
enabled auto-merge
May 7, 2026 14:50
Merged
via the queue into
open-telemetry:main
with commit May 7, 2026
e18edf9
32 of 34 checks passed
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:
Adding a method to read pipeline initialization from declarative config, or if not present failover to a file in yaml (or a json file).
The declarative config looks like
If declarative config is not present, the failover file is expected to have the node under
telemetry_policy, ie starting atsourcesas the top-level nodeExisting Issue(s):
#2546
Testing:
Added
Documentation:
Added
Outstanding items:
Wiring up the policy pipeline:
Steps needed for the wiring: