Class ConfigUtil

java.lang.Object
io.opentelemetry.api.internal.ConfigUtil

public final class ConfigUtil extends Object
Configuration utilities.

This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.

  • Constructor Details

    • ConfigUtil

      private ConfigUtil()
  • Method Details

    • safeSystemProperties

      public static Properties 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

      public static String getString(String key, String defaultValue)
      Return the system property or environment variable for the key.

      Normalize the key using normalizePropertyKey(String). Match to system property keys also normalized with normalizePropertyKey(String). Match to environment variable keys normalized with normalizeEnvironmentVariableKey(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

      public static String normalizeEnvironmentVariableKey(String key)
      Normalize an environment variable key by converting to lower case and replacing "_" with ".".
    • normalizePropertyKey

      public static String normalizePropertyKey(String key)
      Normalize a property key by converting to lower case and replacing "-" with ".".
    • defaultIfNull

      public static <T> T defaultIfNull(@Nullable T value, T defaultValue)
      Returns defaultValue if value is null, otherwise value. This is an internal method.