Add InstrumentationDefaults helper to declarative-config-bridge#17816
Add InstrumentationDefaults helper to declarative-config-bridge#17816zeitlinger wants to merge 16 commits into
Conversation
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>
f25ec01 to
4559fdf
Compare
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>
|
@jack-berg fyi - since we talked about it |
|
@robsunday could you help reviewing this |
…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>
trask
left a comment
There was a problem hiding this comment.
From review.py:
Found one config mapping issue in the new InstrumentationDefaults helper.
is that supposed to show here? |
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>
this is just me running it locally, haven't automated it yet, I typed that part 😄 |
…ot observable Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
There was a problem hiding this comment.
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
InstrumentationDefaultsAPI to collect defaults in underscore notation and translate them tootel.instrumentation.*property keys. - Added support for applying defaults into the declarative-config model under
instrumentation/development.javawithout 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. |
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>
Summary
InstrumentationDefaultsto thedeclarative-config-bridgemodule — a utility for distributions to define instrumentation property defaults once and have them work in both configuration modessetDefault(instrumentation, key, value)(fluent, returnsthis) stores defaults using underscore notationtoConfigProperties()translates to flatotel.instrumentation.*property map (underscore→hyphen) for traditional auto-configurationapplyToModel(OpenTelemetryConfigurationModel)injects defaults into the DC model underinstrumentation/development.java, usingputIfAbsentso explicit user config always winsExtracted from grafana/grafana-opentelemetry-java#1226, which noted a TODO to propose this as a shared utility.
Test plan
InstrumentationDefaultsTestcoverstoConfigProperties(),applyToModel(), and the non-override semantics./gradlew :declarative-config-bridge:testpasses