Class Config


  • public abstract class Config
    extends Object
    Represents the global agent configuration consisting of system properties, environment variables, contents of the agent configuration file and properties defined by the ConfigPropertySource SPI (see ConfigInitializer and ConfigBuilder).

    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 Config. Agent configuration does not change during the runtime so retrieving the property once and storing its result in e.g. static final field allows JIT to do its magic and remove some code branches.

    • Method Detail

      • internalInitializeConfig

        public static void internalInitializeConfig​(Config config)
        Sets the agent configuration singleton. This method is only supposed to be called once, from the agent classloader just before the first instrumentation is loaded (and before get() is used for the first time).
      • get

        public static Config get()
        Returns the global agent configuration.
      • getAllProperties

        public abstract Map<String,​String> getAllProperties()
        Returns all properties stored in this instance. The returned map is unmodifiable.
      • getProperty

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

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

        public 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

        public @Nullable Boolean getBoolean​(String name)
        Returns a boolean-valued configuration property or null if a property with name name has not been configured.
      • getBoolean

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

        @Deprecated
        public boolean getBooleanProperty​(String name,
                                          boolean defaultValue)
        Deprecated.
        Returns a boolean-valued configuration property or defaultValue if a property with name name has not been configured.
      • getInt

        public @Nullable Integer getInt​(String name)
        Returns a integer-valued configuration property or null if a property with name name has not been configured.
      • getInt

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

        public @Nullable Long getLong​(String name)
        Returns a long-valued configuration property or null if a property with name name has not been configured.
      • getLong

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

        public @Nullable Double getDouble​(String name)
        Returns a double-valued configuration property or null if a property with name name has not been configured.
      • getDouble

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

        public @Nullable Duration getDuration​(String name)
        Returns a duration-valued configuration property or null if a property with name name has not been configured.

        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.

      • getDuration

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

        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.

      • getListProperty

        @Deprecated
        public List<String> getListProperty​(String name)
        Deprecated.
        Use getList(String) instead.
        Returns a list-valued configuration property or an empty list 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.
      • getListProperty

        @Deprecated
        public List<String> getListProperty​(String name,
                                            List<String> defaultValue)
        Deprecated.
        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.
      • getList

        public List<String> getList​(String name)
        Returns a list-valued configuration property or an empty list 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.
      • getList

        public 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.
      • getMapProperty

        @Deprecated
        public Map<String,​String> getMapProperty​(String name)
        Deprecated.
        Use getMap(String, Map) instead.
        Returns a map-valued configuration property or an empty map if a property with name name has not been configured. 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.
      • getMap

        public Map<String,​String> getMap​(String name)
        Returns a map-valued configuration property or an empty map if a property with name name has not been configured. 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.
      • getMap

        public 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. 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.
      • isInstrumentationEnabled

        public boolean isInstrumentationEnabled​(Iterable<String> instrumentationNames,
                                                boolean defaultEnabled)
      • isInstrumentationPropertyEnabled

        public boolean isInstrumentationPropertyEnabled​(Iterable<String> instrumentationNames,
                                                        String suffix,
                                                        boolean defaultEnabled)
      • isAgentDebugEnabled

        public boolean isAgentDebugEnabled()