Skip to content

[dynamic control] propagate SourceKind across validation and policy creation#2973

Merged
jaydeluca merged 1 commit into
open-telemetry:mainfrom
jackshirazi:policy-phase2-16
Jul 13, 2026
Merged

[dynamic control] propagate SourceKind across validation and policy creation#2973
jaydeluca merged 1 commit into
open-telemetry:mainfrom
jackshirazi:policy-phase2-16

Conversation

@jackshirazi

Copy link
Copy Markdown
Contributor

Description:

This PR is mainly the addition of a SourceKind parameter to methods, plus additional tests.

The spec requires opamp > http > file priority of policies so if mergeable policies are received by more than one source in an update, the highest priority policy is retained and the others dropped. This PR propagates the source and starts using the source-aware policies. Dropping the policies is implemented in a following PR

Existing Issue(s):

#2868

Testing:

not yet

Documentation:

n/a

Outstanding items:

Still to implement

  • retaining source in the policies
    • drop now unused methods/constructors/defaults which are not source aware
  • dropping lower priority policies in an update when the policies are otherwise mergeable in an update, by changing policy aggregation in the PolicyStore

Also #2868

Copilot AI review requested due to automatic review settings July 9, 2026 11:38
@jackshirazi
jackshirazi requested a review from a team as a code owner July 9, 2026 11:38
@github-actions
github-actions Bot requested a review from LikeTheSalad July 9, 2026 11:39

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.

Pull request overview

This PR updates the dynamic-control policy pipeline to propagate a SourceKind (e.g., OPAMP vs FILE) through validation and into created TelemetryPolicy instances, enabling later spec-compliant source-priority handling.

Changes:

  • Extends PolicyValidator / AbstractSourcePolicyValidator validation APIs to accept a SourceKind and threads it through JSON/key-value validation paths.
  • Updates OpAMP and file-based policy providers to pass the correct SourceKind into validation.
  • Expands unit tests to assert that validated/constructed policies retain the provided source kind.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/PolicyValidator.java Extends validator API to accept SourceKind during validation.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/AbstractSourcePolicyValidator.java Propagates SourceKind through source-format dispatch and into abstract validation hooks.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingValidator.java Passes SourceKind through trace-sampling policy validation and construction.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/OpampPolicyProvider.java Supplies SourceKind.OPAMP when validating parsed OpAMP policies.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/LinePerPolicyFileProvider.java Supplies SourceKind.FILE when validating policies read from a file.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingValidatorTest.java Asserts validator propagates SourceKind into produced policies.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRatePolicyTest.java Asserts policy constructors store default/explicit SourceKind.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingRatePolicyImplementerTest.java Updates test policy stubs to implement getSourceKind().
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/registry/PolicyInitTest.java Updates test policy stubs to carry SourceKind.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/LinePerPolicyFileProviderTest.java Asserts file provider results carry SourceKind.FILE and updates validator stub signature.
dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/DeletedTelemetryPolicyTest.java Asserts deleted policies retain default/explicit SourceKind and updates stubs.

@jaydeluca
jaydeluca added this pull request to the merge queue Jul 13, 2026
Merged via the queue into open-telemetry:main with commit de83f81 Jul 13, 2026
24 checks passed
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.

4 participants