Package io.opentelemetry.api.internal
Class ConfigUtil
java.lang.Object
io.opentelemetry.api.internal.ConfigUtil
Configuration utilities.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
defaultIfNull
(T value, T defaultValue) Returns defaultValue if value is null, otherwise value.static String
Return the system property or environment variable for thekey
.static String
Normalize an environment variable key by converting to lower case and replacing "_" with ".".static String
Normalize a property key by converting to lower case and replacing "-" with ".".static Properties
Returns a copy of system properties which is safe to iterate over.
-
Constructor Details
-
ConfigUtil
private ConfigUtil()
-
-
Method Details
-
safeSystemProperties
Returns a copy of system properties which is safe to iterate over.In java 8 and android environments, iterating through system properties may trigger
ConcurrentModificationException
. This method ensures callers can iterate safely without risk of exception. See https://github.com/open-telemetry/opentelemetry-java/issues/6732 for details. -
getString
Return the system property or environment variable for thekey
.Normalize the
key
usingnormalizePropertyKey(String)
. Match to system property keys also normalized withnormalizePropertyKey(String)
. Match to environment variable keys normalized withnormalizeEnvironmentVariableKey(String)
. System properties take priority over environment variables.- Parameters:
key
- the property key- Returns:
- the system property if not null, or the environment variable if not null, or
defaultValue
-
normalizeEnvironmentVariableKey
Normalize an environment variable key by converting to lower case and replacing "_" with ".". -
normalizePropertyKey
Normalize a property key by converting to lower case and replacing "-" with ".". -
defaultIfNull
Returns defaultValue if value is null, otherwise value. This is an internal method.
-