-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add contrib-facing helpers to the declarative config bridge #19220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 24 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
352c7f0
feat: Replace DeclarativeConfigPropertiesBridge with ConfigProperties…
aviralgarg05 4455375
fix: Resolve build and formatting issues
aviralgarg05 ceefeb5
Suppress deprecation warnings for backward compatibility
aviralgarg05 c720a10
Merge upstream/main into fix/issue-15811
aviralgarg05 fa9133d
Address PR feedback: preserve special mappings and track 3.0 removal
aviralgarg05 8270514
Merge remote-tracking branch 'upstream/main' into fix/issue-15811
trask 8213aed
Address remaining PR review feedback
aviralgarg05 b432212
Merge branch 'main' into fix/issue-15811
aviralgarg05 d02c1de
Merge remote-tracking branch 'upstream/main' into fix/issue-15811
trask 74b8b25
Address remaining PR review feedback
aviralgarg05 346ed3d
Merge remote-tracking branch 'upstream/main' into fix/issue-15811
aviralgarg05 151b681
Merge remote-tracking branch 'origin/fix/issue-15811' into fix/issue-…
aviralgarg05 aaa02b3
fix: use Java-compatible empty map in config provider test
aviralgarg05 c1683da
fix: satisfy spotless for config provider test
aviralgarg05 7a34a99
configurable access path
zeitlinger 15ce857
Merge remote-tracking branch 'origin/main' into cp-bridge-for-distros
zeitlinger 7e7938f
add DeclarativeConfigPropertiesDurationUtil
zeitlinger 2bc1684
Add contrib-facing declarative bridge helpers
zeitlinger 640ea3c
cleanup
zeitlinger c825e84
Fix component provider example in bridge README
zeitlinger 55f9e56
Update declarative-config-bridge/src/main/java/io/opentelemetry/instr…
zeitlinger 05d1972
Fix declarative config bridge review findings
trask 19e9f58
Rename declarative duration helper
trask 264b8bd
Simplify declarative config bridge API
trask e8b277f
Scope deprecated API suppression
trask 1aabda1
Address review comment from copilot-pull-request-reviewer: isolate co…
trask 174e659
Address review comment from copilot-pull-request-reviewer: correct pr…
trask 10fda27
Address review comment from copilot-pull-request-reviewer: narrow hel…
trask 5920f40
Address review comment from copilot-pull-request-reviewer: document b…
trask 8c61aa3
Merge remote-tracking branch 'upstream/main' into cp-bridge-for-contrib
trask eae11a0
spotless
trask File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...src/main/java/io/opentelemetry/instrumentation/config/bridge/DeclarativeConfigBridge.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.config.bridge; | ||
|
|
||
| import io.opentelemetry.api.incubator.config.ConfigProvider; | ||
| import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
|
|
||
| /** Exposes flat {@link ConfigProperties} through the declarative configuration APIs. */ | ||
| public final class DeclarativeConfigBridge { | ||
|
trask marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Creates the complete declarative instrumentation configuration backed by flat {@link | ||
| * ConfigProperties}. | ||
| */ | ||
| public static ConfigProvider createInstrumentationConfig(ConfigProperties configProperties) { | ||
| return createConfigProvider( | ||
| ConfigPropertiesBackedDeclarativeConfigProperties.createInstrumentationConfig( | ||
| configProperties)); | ||
| } | ||
|
|
||
| /** | ||
| * Creates component-local declarative properties backed by flat {@link ConfigProperties}. | ||
| * | ||
| * <p>The returned properties have the same root-relative shape as the properties passed to a | ||
| * declarative {@code ComponentProvider}. For example, a component can read {@code enabled} while | ||
| * the bridge resolves the value from {@code configPropertyPrefix + "enabled"}. | ||
| */ | ||
|
trask marked this conversation as resolved.
|
||
| public static DeclarativeConfigProperties createComponentProperties( | ||
| ConfigProperties configProperties, String configPropertyPrefix) { | ||
| return ConfigPropertiesBackedDeclarativeConfigProperties.createComponentProperties( | ||
| configProperties, configPropertyPrefix); | ||
| } | ||
|
|
||
| static ConfigProvider createConfigProvider(DeclarativeConfigProperties instrumentationConfig) { | ||
|
trask marked this conversation as resolved.
Outdated
|
||
| return new BridgedConfigProvider(instrumentationConfig); | ||
| } | ||
|
|
||
| private DeclarativeConfigBridge() {} | ||
|
|
||
| private static final class BridgedConfigProvider implements ConfigProvider { | ||
| private final DeclarativeConfigProperties instrumentationConfig; | ||
|
|
||
| private BridgedConfigProvider(DeclarativeConfigProperties instrumentationConfig) { | ||
| this.instrumentationConfig = instrumentationConfig; | ||
| } | ||
|
|
||
| @Override | ||
| public DeclarativeConfigProperties getInstrumentationConfig() { | ||
| return instrumentationConfig; | ||
| } | ||
| } | ||
| } | ||
46 changes: 46 additions & 0 deletions
46
...in/java/io/opentelemetry/instrumentation/config/bridge/DeclarativeConfigDurationUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.config.bridge; | ||
|
|
||
| import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; | ||
| import java.time.Duration; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Helpers for reading duration values from {@link DeclarativeConfigProperties}. | ||
| * | ||
| * <p>When the config is backed by flat {@link | ||
| * io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties}, duration strings such as {@code 42ms} | ||
| * are supported by delegating to the SDK's standard duration parser. | ||
| * | ||
| * <p>For other declarative-config implementations, this utility expects duration values to already | ||
| * be normalized to integer milliseconds, which means string durations in declarative YAML are not | ||
| * accepted. | ||
| */ | ||
| public final class DeclarativeConfigDurationUtil { | ||
|
|
||
| /** | ||
| * Reads a duration from declarative config. | ||
| * | ||
| * <p>String duration values are only supported when {@code properties} is a {@link | ||
| * ConfigPropertiesBackedDeclarativeConfigProperties}. Other implementations must provide integer | ||
| * milliseconds for the same key. | ||
| */ | ||
| @Nullable | ||
| public static Duration getDuration(DeclarativeConfigProperties properties, String key) { | ||
| if (properties instanceof ConfigPropertiesBackedDeclarativeConfigProperties) { | ||
| return ((ConfigPropertiesBackedDeclarativeConfigProperties) properties).getDuration(key); | ||
| } | ||
|
|
||
| Long rawLongValue = properties.getLong(key); | ||
| if (rawLongValue == null) { | ||
| return null; | ||
| } | ||
| return Duration.ofMillis(rawLongValue); | ||
| } | ||
|
|
||
| private DeclarativeConfigDurationUtil() {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.