Skip to content

Add InstrumentationDefaults helper to declarative-config-bridge#17816

Open
zeitlinger wants to merge 16 commits into
open-telemetry:mainfrom
zeitlinger:instrumentation-defaults
Open

Add InstrumentationDefaults helper to declarative-config-bridge#17816
zeitlinger wants to merge 16 commits into
open-telemetry:mainfrom
zeitlinger:instrumentation-defaults

Conversation

@zeitlinger

Copy link
Copy Markdown
Member

Summary

  • Adds InstrumentationDefaults to the declarative-config-bridge module — a utility for distributions to define instrumentation property defaults once and have them work in both configuration modes
  • setDefault(instrumentation, key, value) (fluent, returns this) stores defaults using underscore notation
  • toConfigProperties() translates to flat otel.instrumentation.* property map (underscore→hyphen) for traditional auto-configuration
  • applyToModel(OpenTelemetryConfigurationModel) injects defaults into the DC model under instrumentation/development.java, using putIfAbsent so explicit user config always wins

Extracted from grafana/grafana-opentelemetry-java#1226, which noted a TODO to propose this as a shared utility.

Test plan

  • InstrumentationDefaultsTest covers toConfigProperties(), applyToModel(), and the non-override semantics
  • ./gradlew :declarative-config-bridge:test passes

Provides a utility for distributions to define instrumentation property
defaults once and have them work with both traditional property-based
configuration (otel.instrumentation.*) and declarative configuration
(YAML model under instrumentation/development.java).

Extracted from grafana/grafana-opentelemetry-java#1226.
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger force-pushed the instrumentation-defaults branch from f25ec01 to 4559fdf Compare April 10, 2026 18:04
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…README

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger marked this pull request as ready for review April 13, 2026 17:32
@zeitlinger zeitlinger requested a review from a team as a code owner April 13, 2026 17:32
@zeitlinger

Copy link
Copy Markdown
Member Author

@jack-berg fyi - since we talked about it

@laurit

laurit commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

@robsunday could you help reviewing this

Comment thread declarative-config-bridge/README.md Outdated
@zeitlinger zeitlinger marked this pull request as draft April 16, 2026 14:52
…readme to match DC API pattern

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Replace vararg setDefault(instr, key, value) with nested
defaults.get(name).setDefault(key, value). Mirrors
DeclarativeConfigProperties.getStructured(name).getString(key)
on the read side. README notes the symmetry.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…symmetry note

DeclarativeConfigProperties.get(name) (added in open-telemetry/opentelemetry-java#7923)
is the standard read-side API; update InstrumentationDefaults javadoc and README to
match.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger marked this pull request as ready for review April 18, 2026 08:50

@trask trask left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From review.py:


Found one config mapping issue in the new InstrumentationDefaults helper.

@zeitlinger

Copy link
Copy Markdown
Member Author

From review.py:

is that supposed to show here?

zeitlinger added 3 commits May 4, 2026 11:55
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@trask

trask commented May 4, 2026

Copy link
Copy Markdown
Member

From review.py:

is that supposed to show here?

this is just me running it locally, haven't automated it yet, I typed that part 😄

@zeitlinger zeitlinger requested a review from trask May 5, 2026 06:27
@github-actions github-actions Bot mentioned this pull request May 5, 2026
Comment thread declarative-config-bridge/README.md
…ot observable

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.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.

Pull request overview

This pull request introduces an InstrumentationDefaults helper in the declarative-config-bridge module to let distribution authors define instrumentation configuration defaults once and apply them both to classic otel.instrumentation.* properties and to the declarative-config model.

Changes:

  • Added InstrumentationDefaults API to collect defaults in underscore notation and translate them to otel.instrumentation.* property keys.
  • Added support for applying defaults into the declarative-config model under instrumentation/development.java without overriding user-provided values.
  • Added unit tests and README documentation describing intended usage patterns.

Reviewed changes

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

File Description
declarative-config-bridge/src/main/java/io/opentelemetry/instrumentation/config/bridge/InstrumentationDefaults.java New helper class for defining defaults, translating to property keys, and injecting into the DC model.
declarative-config-bridge/src/test/java/io/opentelemetry/instrumentation/config/bridge/InstrumentationDefaultsTest.java New tests covering property translation, bridge round-trip, and non-override semantics in the model.
declarative-config-bridge/README.md Added documentation and examples for using InstrumentationDefaults in both configuration modes.
declarative-config-bridge/build.gradle.kts Added a compileOnly dependency on the SDK incubator extension for model types.

Comment thread declarative-config-bridge/README.md
Comment thread declarative-config-bridge/build.gradle.kts Outdated
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.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.

5 participants