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> TdefaultIfNull(T value, T defaultValue) Returns defaultValue if value is null, otherwise value.static StringReturn the system property or environment variable for thekey.static StringNormalize an environment variable key by converting to lower case and replacing "_" with ".".static StringNormalize a property key by converting to lower case and replacing "-" with ".".static PropertiesReturns 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
keyusingnormalizePropertyKey(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
-
normalizePropertyKey
-
defaultIfNull
Returns defaultValue if value is null, otherwise value. This is an internal method.
-