Interface InstrumentationConfig


public interface InstrumentationConfig
Represents the global instrumentation configuration consisting of system properties, environment variables, contents of the agent configuration file and properties defined by the ConfigPropertySource SPI implementations.

In case any get*() method variant gets called for the same property more than once (e.g. each time an advice class executes) it is suggested to cache the result instead of repeatedly calling InstrumentationConfig. Instrumentation configuration does not change during the runtime so retrieving the property once and storing its result in a static final field allows JIT to do its magic and remove some code branches.

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

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    getBoolean(String name, boolean defaultValue)
    Returns a boolean-valued configuration property or defaultValue if a property with name name has not been configured.
    io.opentelemetry.api.incubator.config.ConfigProvider
    Returns the ConfigProvider if declarative configuration is used.
    io.opentelemetry.api.incubator.config.DeclarativeConfigProperties
    Returns a DeclarativeConfigProperties for the given node name, which is usually an instrumentation name
    double
    getDouble(String name, double defaultValue)
    Returns a double-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed.
    getDuration(String name, Duration defaultValue)
    Returns a duration-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed.
    int
    getInt(String name, int defaultValue)
    Returns an integer-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed.
    default List<String>
    This is the same as calling getList(String, List) with the defaultValue equal to the emptyList()/
    getList(String name, List<String> defaultValue)
    Returns a list-valued configuration property or defaultValue if a property with name name has not been configured.
    long
    getLong(String name, long defaultValue)
    Returns a long-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed.
    getMap(String name, Map<String,String> defaultValue)
    Returns a map-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed.
    Returns a string-valued configuration property or null if a property with name name has not been configured.
    getString(String name, String defaultValue)
    Returns a string-valued configuration property or defaultValue if a property with name name has not been configured.
    boolean
    Returns true if declarative configuration is used in this configuration.
  • Method Details

    • getString

      @Nullable String getString(String name)
      Returns a string-valued configuration property or null if a property with name name has not been configured.
    • getString

      String getString(String name, String defaultValue)
      Returns a string-valued configuration property or defaultValue if a property with name name has not been configured.
    • getBoolean

      boolean getBoolean(String name, boolean defaultValue)
      Returns a boolean-valued configuration property or defaultValue if a property with name name has not been configured.
    • getInt

      int getInt(String name, int defaultValue)
      Returns an integer-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed.
    • getLong

      long getLong(String name, long defaultValue)
      Returns a long-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed.
    • getDouble

      double getDouble(String name, double defaultValue)
      Returns a double-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed.
    • getDuration

      Duration getDuration(String name, Duration defaultValue)
      Returns a duration-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed.

      Durations can be of the form "{number}{unit}", where unit is one of:

      • ms
      • s
      • m
      • h
      • d

      If no unit is specified, milliseconds is the assumed duration unit.

      Examples: 10s, 20ms, 5000

    • getList

      default List<String> getList(String name)
      This is the same as calling getList(String, List) with the defaultValue equal to the emptyList()/
    • getList

      List<String> getList(String name, List<String> defaultValue)
      Returns a list-valued configuration property or defaultValue if a property with name name has not been configured. The format of the original value must be comma-separated, e.g. one,two,three. The returned list is unmodifiable.
    • getMap

      Map<String,String> getMap(String name, Map<String,String> defaultValue)
      Returns a map-valued configuration property or defaultValue if a property with name name has not been configured or when parsing has failed. The format of the original value must be comma-separated for each key, with an '=' separating the key and value, e.g. key=value,anotherKey=anotherValue. The returned map is unmodifiable.
    • isDeclarative

      boolean isDeclarative()
      Returns true if declarative configuration is used in this configuration.
    • getDeclarativeConfig

      io.opentelemetry.api.incubator.config.DeclarativeConfigProperties getDeclarativeConfig(String node)
      Returns a DeclarativeConfigProperties for the given node name, which is usually an instrumentation name

      Call isDeclarative() first to check if declarative configuration is used.

      Declarative configuration is used to configure instrumentation properties in a declarative way, such as through YAML or JSON files.

      Parameters:
      node - the name of the instrumentation (e.g. "log4j"), the vendor name (e.g. "google"), or "common" for common Java settings that don't apply to other languages.
      Returns:
      the declarative configuration properties for the given node name
      Throws:
      IllegalStateException - if isDeclarative() returns false
    • getConfigProvider

      @Nullable io.opentelemetry.api.incubator.config.ConfigProvider getConfigProvider()
      Returns the ConfigProvider if declarative configuration is used.
      Returns:
      the ConfigProvider or null if no provider is available