-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Add ConfigPropertiesBackedConfigProvider options for extensions and distros #15835
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
Open
aviralgarg05
wants to merge
8
commits into
open-telemetry:main
Choose a base branch
from
aviralgarg05:fix/issue-15811
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 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 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
67 changes: 67 additions & 0 deletions
67
...opentelemetry/instrumentation/config/bridge/ConfigPropertiesBackedConfigProviderTest.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,67 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.config.bridge; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import io.opentelemetry.api.incubator.config.ConfigProvider; | ||
| import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class ConfigPropertiesBackedConfigProviderTest { | ||
| @Test | ||
| void testBuilderWithMappings() { | ||
| Map<String, String> properties = new HashMap<>(); | ||
| properties.put("my.custom.property", "custom-value"); | ||
|
|
||
| // ConfigProperties has "my.custom.property" | ||
| // We want to map declarative "my.declarative.prop" to "my.custom.property" | ||
|
|
||
| ConfigProvider provider = | ||
| ConfigPropertiesBackedConfigProvider.builder() | ||
| .addMapping("my.declarative.prop", "my.custom.property") | ||
| .build(DefaultConfigProperties.createFromMap(properties)); | ||
|
|
||
| DeclarativeConfigProperties config = provider.getInstrumentationConfig(); | ||
|
|
||
| // DeclarativeConfigProperties structure lookup | ||
| // pathWithName("my.declarative.prop") should map to "my.custom.property" | ||
| // However, structure is hierarchical. | ||
| // getStructured("my").getStructured("declarative").getString("prop") -> | ||
| // "my.declarative.prop" | ||
|
|
||
| assertThat(config.getStructured("my").getStructured("declarative").getString("prop")) | ||
| .isEqualTo("custom-value"); | ||
| } | ||
|
|
||
| @Test | ||
| void testCreateUsesDefaults() { | ||
| // Verify that create() still supports the default mappings (e.g. | ||
| // otel.instrumentation...) | ||
| // e.g. "java.common.http.known_methods" -> | ||
| // "otel.instrumentation.http.known-methods" | ||
|
|
||
| Map<String, String> properties = new HashMap<>(); | ||
| properties.put("otel.instrumentation.http.known-methods", "GET,POST"); | ||
|
|
||
| ConfigProvider provider = | ||
| ConfigPropertiesBackedConfigProvider.create( | ||
| DefaultConfigProperties.createFromMap(properties)); | ||
|
|
||
| DeclarativeConfigProperties config = provider.getInstrumentationConfig(); | ||
|
|
||
| assertThat( | ||
| config | ||
| .getStructured("java") | ||
| .getStructured("common") | ||
| .getStructured("http") | ||
| .getString("known_methods")) | ||
| .isEqualTo("GET,POST"); | ||
| } | ||
| } |
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.