-
Notifications
You must be signed in to change notification settings - Fork 1k
Add system properties bridge #15339
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
Closed
zeitlinger
wants to merge
54
commits into
open-telemetry:main
from
zeitlinger:system-properties-bridge
Closed
Add system properties bridge #15339
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
d572c69
add system properties bridge
zeitlinger 2770d86
add system properties bridge
zeitlinger 5a3c8dd
add tests
zeitlinger e29c7bb
add list
zeitlinger 0626c95
refactor
zeitlinger efaef9f
refactor
zeitlinger bd9a69f
string
zeitlinger 07cc6fa
string
zeitlinger 7a64c91
string
zeitlinger cf01131
string
zeitlinger e3a1e60
string
zeitlinger 8b22e17
string
zeitlinger 73ec70c
string
zeitlinger f9f3df8
string
zeitlinger 93f173f
javadoc
zeitlinger 76b4683
add contract
zeitlinger cb3931b
add contract
zeitlinger f2fd6c4
remove contract
zeitlinger e7558dc
remove contract
zeitlinger 1ee4e6d
inline method to avoid class not found exception for DeclarativeConfi…
zeitlinger 8329a1e
pr review
zeitlinger aebd419
use optional instead of providing default for boolean
zeitlinger 0bd5b32
use optional instead of providing default for int
zeitlinger 65c7f44
use optional instead of providing default for list
zeitlinger eae795e
use optional instead of providing default for string
zeitlinger 80e8567
fix
zeitlinger 7e1f313
fix
zeitlinger 7acb8d2
fix
zeitlinger 77741fa
split pr
zeitlinger f3a6303
split pr
zeitlinger 6b9fe65
fix
zeitlinger d4e6219
fix
zeitlinger 165a99b
pr review
zeitlinger 28c9472
revert aws test
zeitlinger 5d845ac
use "/development" instead of "experimental" in declarative config
zeitlinger 75a4c5f
use "/development" instead of "experimental" in declarative config
zeitlinger c6e8b7c
fix
zeitlinger 7d33506
docs
zeitlinger b9695fc
avoid double bridge
zeitlinger dd9657d
normalize system props before lookup to avoid ambiguity of "experimen…
zeitlinger a390973
normalize system props before lookup to avoid ambiguity of "experimen…
zeitlinger a399bb8
normalize system props before lookup to avoid ambiguity of "experimen…
zeitlinger 9c42e5a
normalize system props before lookup to avoid ambiguity of "experimen…
zeitlinger ee4d8ac
rename js snippet property
zeitlinger dbda350
normalize system props before lookup to avoid ambiguity of "experimen…
zeitlinger 7bbf141
add changelog
zeitlinger e3fa175
format
zeitlinger ff31147
remove param that is always false
zeitlinger 5dff2c2
remove performance optimization
zeitlinger 753419e
remove performance optimization
zeitlinger 708ff2a
avoid lambda in early phase
zeitlinger 533555d
deprecated fallback
trask a6abcb6
cleanup
zeitlinger c5bfe9c
fix experimental in the middle
zeitlinger 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
Some comments aren't visible on the classic Files Changed page.
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
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
81 changes: 81 additions & 0 deletions
81
...mentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/ConfigUtil.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,81 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.internal; | ||
|
|
||
| import java.util.ConcurrentModificationException; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
| import java.util.Properties; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Configuration utilities. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| * | ||
| * <p>Copied from <a | ||
| * href="https://github.com/open-telemetry/opentelemetry-java/blob/main/api/all/src/main/java/io/opentelemetry/api/internal/ConfigUtil.java">SDK</a> | ||
| * because some tests target an SDK version where this class does not exist. | ||
| */ | ||
| final class ConfigUtil { | ||
|
|
||
| private ConfigUtil() {} | ||
|
|
||
| /** | ||
| * Returns a copy of system properties which is safe to iterate over. | ||
| * | ||
| * <p>In java 8 and android environments, iterating through system properties may trigger {@link | ||
| * ConcurrentModificationException}. This method ensures callers can iterate safely without risk | ||
| * of exception. See https://github.com/open-telemetry/opentelemetry-java/issues/6732 for details. | ||
| */ | ||
| public static Properties safeSystemProperties() { | ||
| return (Properties) System.getProperties().clone(); | ||
| } | ||
|
|
||
| /** | ||
| * Return the system property or environment variable for the {@code key}. | ||
| * | ||
| * <p>Normalize the {@code key} using {@link #normalizePropertyKey(String)}. Match to system | ||
| * property keys also normalized with {@link #normalizePropertyKey(String)}. Match to environment | ||
| * variable keys normalized with {@link #normalizeEnvironmentVariableKey(String)}. System | ||
| * properties take priority over environment variables. | ||
| * | ||
| * @param key the property key | ||
| * @return the system property if not null, or the environment variable if not null, or {@code | ||
| * null} | ||
| */ | ||
| @Nullable | ||
| public static String getString(String key) { | ||
| String normalizedKey = normalizePropertyKey(key); | ||
|
|
||
| for (Map.Entry<Object, Object> entry : safeSystemProperties().entrySet()) { | ||
| if (normalizedKey.equals(normalizePropertyKey(entry.getKey().toString()))) { | ||
| return entry.getValue().toString(); | ||
| } | ||
| } | ||
|
|
||
| for (Map.Entry<String, String> entry : System.getenv().entrySet()) { | ||
| if (normalizedKey.equals(normalizeEnvironmentVariableKey(entry.getKey()))) { | ||
| return entry.getValue(); | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Normalize an environment variable key by converting to lower case and replacing "_" with ".". | ||
| */ | ||
| public static String normalizeEnvironmentVariableKey(String key) { | ||
| return key.toLowerCase(Locale.ROOT).replace("_", "."); | ||
| } | ||
|
|
||
| /** Normalize a property key by converting to lower case and replacing "-" with ".". */ | ||
| public static String normalizePropertyKey(String key) { | ||
| return key.toLowerCase(Locale.ROOT).replace("-", "."); | ||
| } | ||
| } |
Oops, something went wrong.
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.