Skip to content

[dynamic control] refactor OpampPolicyProvider for other PolicyProviders#2987

Open
jackshirazi wants to merge 5 commits into
open-telemetry:mainfrom
jackshirazi:policy-phase2-19
Open

[dynamic control] refactor OpampPolicyProvider for other PolicyProviders#2987
jackshirazi wants to merge 5 commits into
open-telemetry:mainfrom
jackshirazi:policy-phase2-19

Conversation

@jackshirazi

Copy link
Copy Markdown
Contributor

Description:

This is a straightforward refactor of behaviour in OpampPolicyProvider that other PolicyProviders will need to use (file and http providers). There are two separate refactors

  • The policy snapshot from reading an incoming message is moved into an abstract superclass
  • The mapping between policy ID and policy type (the incoming message has an ID but that maps into a concrete policy implementation after checking that the policy message is a valid message) is moved into a delegated helper class

Existing Issue(s):

#2868

Testing:

Already present, no changes needed

Documentation:

not needed for the refactoring

Outstanding items:

#2868

Copilot AI review requested due to automatic review settings July 13, 2026 12:35
@jackshirazi jackshirazi requested a review from a team as a code owner July 13, 2026 12:35
@github-actions github-actions Bot requested a review from LikeTheSalad July 13, 2026 12:36

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

Refactors the dynamic-control OpAMP policy provider to extract reusable behavior needed by upcoming policy providers (e.g., file and HTTP providers), specifically around maintaining a current policy snapshot and mapping/validating incoming policy IDs into concrete policy types.

Changes:

  • Introduced AbstractPolicyProvider to centralize “current policies snapshot” storage/update + update notifications.
  • Introduced MappedPolicySourceConverter to encapsulate policy-id → policy-type mapping and validator-based conversion.
  • Updated OpampPolicyProvider to extend the new base class and delegate mapping/validation to the new converter.

Reviewed changes

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

File Description
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/OpampPolicyProvider.java Refactored to use shared snapshot management and delegated policy mapping/validation.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/MappedPolicySourceConverter.java New helper to map incoming policy IDs to internal policy types and validate/convert sources into TelemetryPolicy.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/AbstractPolicyProvider.java New base class providing a thread-safe immutable snapshot of current policies plus update notification helper.

jackshirazi and others added 2 commits July 13, 2026 14:14
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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