Skip to content

[dynamic control] support the current spec structure - #3037

Open
jackshirazi wants to merge 10 commits into
open-telemetry:mainfrom
jackshirazi:policy-phase2-22
Open

[dynamic control] support the current spec structure#3037
jackshirazi wants to merge 10 commits into
open-telemetry:mainfrom
jackshirazi:policy-phase2-22

Conversation

@jackshirazi

Copy link
Copy Markdown
Contributor

Description:

Align to spec, supporting the fuller message structure for JSON structures.

Primarily this adds parsing in the JsonSourceWrapper, and some smaller changes in other classes that use that source wrapper supported by a new interface method. Plus a bunch of tests

Existing Issue(s):

#2868

Testing:

changed as needed

Documentation:

changed as needed

Outstanding items:

#2868

@jackshirazi
jackshirazi requested a review from a team as a code owner August 6, 2026 13:11
Copilot AI lite review requested due to automatic review settings August 6, 2026 13:11
@github-actions
github-actions Bot requested a review from LikeTheSalad August 6, 2026 13:11

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.

🟡 Changes recommended

There are several fixable issues in the changed code/docs (Javadoc mismatch vs behavior, unnecessary log-message allocations, Markdown formatting, and a binary-compatibility risk from adding a method to a public interface).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Aligns the dynamic-control JSON ingestion pipeline with the evolving OpenTelemetry spec by supporting “full policy” JSON objects (with id, name, and a single signal target containing match and keep) in addition to the existing keyed {"policy-id": value} shape.

Changes:

  • Extend JsonSourceWrapper parsing to accept full policy objects, unwrap the policy-specific keep value, and support remapping via a new SourceWrapper.withPolicyType(...) API.
  • Update validation/conversion flow (MappedPolicySourceConverter, AbstractSourcePolicyValidator, file provider) to operate on the normalized/remapped source and to validate against unwrapped policy values.
  • Add/adjust tests and update README documentation to cover the full policy structure and updated JSON parsing behavior.
File summaries
File Description
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/SourceWrapper.java Adds withPolicyType API for remapping policy identifiers.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/KeyValueSourceWrapper.java Implements withPolicyType for KEYVALUE sources.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/JsonSourceWrapper.java Adds full-policy parsing/validation, getPolicyValue() unwrapping, and remapping behavior.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/MappedPolicySourceConverter.java Switches to SourceWrapper.withPolicyType(...) for normalization/remapping.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/AbstractSourcePolicyValidator.java Validates JSON policies using JsonSourceWrapper.getPolicyType() + getPolicyValue().
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/LinePerPolicyFileProvider.java Accepts per-line full policy JSON via isSinglePolicyObject.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingValidatorTest.java Updates trace sampling JSON tests to use full policy structure + additional envelope checks.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/source/SourceFormatTest.java Updates expectations for multi-key JSON objects (now rejected).
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/source/KeyValueSourceWrapperTest.java Adds withPolicyType immutability/remap behavior test.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/source/JsonSourceWrapperTest.java Adds extensive coverage for full policy parsing, dropping invalid objects, and remapping.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/MappedPolicySourceConverterTest.java New test ensuring full policy remapping does not mutate the original source.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/LinePerPolicyFileProviderTest.java Adds coverage for parsing full-policy JSON lines.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/AbstractSourcePolicyValidatorTest.java New test ensuring validators receive only the unwrapped keep value.
dynamic-control/README.md Documents full policy object support for jsonkeyvalue sources and updates formatting.
Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 4
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread dynamic-control/README.md
jackshirazi and others added 4 commits August 6, 2026 14:59
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

It introduces a couple of concrete correctness/docs issues (notably inconsistent whitespace handling for required text fields and a Markdown list formatting problem) that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (2)

dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/JsonSourceWrapper.java:295

  • hasNonEmptyText trims to check emptiness but otherwise treats leading/trailing whitespace as acceptable, while mapping and policy-id comparisons use the raw asText() value. This inconsistency means an id/name like " trace-sampling " is considered structurally valid but will never match configured mappings, leading to confusing drops. Consider rejecting leading/trailing whitespace explicitly (or normalize consistently).
  private static boolean hasNonEmptyText(@Nullable JsonNode value) {
    return value != null && value.isTextual() && !value.asText().trim().isEmpty();
  }

dynamic-control/README.md:180

  • The JSON example code block isn’t indented under the jsonkeyvalue list item, so it will typically break the surrounding list formatting in Markdown. Indent the fenced block to keep it associated with the bullet item.
    array, and a target `keep` value. The `id` must match a configured `policyId`. For example:

```json
{
  "id": "trace-sampling",
  • Files reviewed: 14/14 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

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