Skip to content

[dynamic control] Add policy config model classes (record-style structure)#2736

Merged
jaydeluca merged 1 commit intoopen-telemetry:mainfrom
jackshirazi:policy17
Apr 2, 2026
Merged

[dynamic control] Add policy config model classes (record-style structure)#2736
jaydeluca merged 1 commit intoopen-telemetry:mainfrom
jackshirazi:policy17

Conversation

@jackshirazi
Copy link
Copy Markdown
Contributor

Description:

This PR adds three immutable, record-type model classes for config initialization

  • PolicyInitConfig
    • sources: List
  • PolicySourceConfig
    • kind: SourceKind
    • format: SourceFormat
    • location: @nullable String
    • mappings: List
  • PolicySourceMappingConfig
    • sourceKey: String
    • policyType: String

Notes

  • Classes are immutable (final fields, defensive copies, unmodifiable lists).
  • Constructors enforce null-safety (including null-element checks for lists).
  • Value semantics provided via equals/hashCode (manual hash implementations).

This would support initialization of the Policy pipeline for examples like the following json or yaml

{
  "sources": [
    {
      "kind": "opamp",
      "format": "jsonkeyvalue",
      "location": "vendor-specific",
      "mappings": [
        { "sourceKey": "sampling_rate", "policyType": "trace_sampling_rate_policy" },
        { "sourceKey": "send_logs", "policyType": "log_export_enabled_policy" }
      ]
    },
    {
      "kind": "file",
      "format": "keyvalue",
      "location": "/some/path/conf.file",
      "mappings": [
        { "sourceKey": "send_metrics", "policyType": "metric_export_enabled_policy" }
      ]
    }
  ]
}
sources:
  - kind: opamp
    format: jsonkeyvalue
    location: vendor-specific
    mappings:
      - sourceKey: sampling_rate
        policyType: trace_sampling_rate_policy
      - sourceKey: send_logs
        policyType: log_export_enabled_policy

  - kind: file
    format: keyvalue
    location: /some/path/conf.file
    mappings:
      - sourceKey: send_metrics
        policyType: metric_export_enabled_policy

Existing Issue(s):

#2546

Testing:

Not needed yet these are just record classes

Documentation:

not needed yet, will be added when specific format parsing is added (eg the above json and/or yaml examples)

Outstanding items:

The functionality to parse json and/or yaml files and create the policy pipeline based on that. Note that the yaml example is exactly what could go into declarative config under a policy pipeline node, so this would naturally migrate to declarative config when it the policy structure is stable and accepted

@jackshirazi jackshirazi requested a review from a team as a code owner April 1, 2026 13:40
Copilot AI review requested due to automatic review settings April 1, 2026 13:40
@github-actions github-actions bot requested a review from LikeTheSalad April 1, 2026 13:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds immutable configuration model classes under dynamic-control to represent initial policy source setup (sources + per-source key→policy mappings). This supports upcoming parsing/initialization work for the dynamic Telemetry Policy pipeline.

Changes:

  • Introduce PolicyInitConfig as a top-level container for configured policy sources.
  • Introduce PolicySourceConfig for per-source configuration (kind/format/location + mappings) with defensive copies and null-element checks.
  • Introduce PolicySourceMappingConfig for individual source-key to policy-type mappings with value semantics.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/registry/PolicyInitConfig.java Adds immutable top-level init config holding a list of PolicySourceConfig.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/registry/PolicySourceConfig.java Adds immutable per-source config (kind/format/location + mappings) with defensive list handling and equals/hashCode.
dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/registry/PolicySourceMappingConfig.java Adds immutable mapping element (sourceKey → policyType) with equals/hashCode.

@jaydeluca jaydeluca added this pull request to the merge queue Apr 2, 2026
Merged via the queue into open-telemetry:main with commit 42fea9d Apr 2, 2026
24 of 25 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