Class Config
- java.lang.Object
-
- io.opentelemetry.instrumentation.api.config.Config
-
public abstract class Config extends Object
-
-
Constructor Summary
Constructors Constructor Description Config()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertiesasJavaProperties()static Configcreate(Map<String,String> allProperties)static Configget()booleangetBooleanProperty(String name, boolean defaultValue)Returns a boolean property value ordefaultValueif a property with namenamedid not exist.List<String>getListProperty(String name)Returns a list-of-strings property value or empty list if a property with namenamedid not exist.List<String>getListProperty(String name, List<String> defaultValue)Returns a list-of-strings property value ordefaultValueif a property with namenamedid not exist.Map<String,String>getMapProperty(String name)Returns a map-of-strings property value or empty map if a property with namenamedid not exist.@Nullable StringgetProperty(String name)Returns a string property value or null if a property with namenamedid not exist.StringgetProperty(String name, String defaultValue)Retrieves a property value from the agent configuration consisting of system properties, environment variables and contents of the agent configuration file (seeConfigInitializerandConfigBuilder).static voidinternalInitializeConfig(Config config)Sets the agent configuration singleton.booleanisInstrumentationEnabled(Iterable<String> instrumentationNames, boolean defaultEnabled)booleanisInstrumentationPropertyEnabled(Iterable<String> instrumentationNames, String suffix, boolean defaultEnabled)
-
-
-
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 beforeget()is used for the first time).
-
get
public static Config get()
-
getProperty
public @Nullable String getProperty(String name)
Returns a string property value or null if a property with namenamedid not exist.- See Also:
getProperty(String, String)
-
getProperty
public String getProperty(String name, String defaultValue)
Retrieves a property value from the agent configuration consisting of system properties, environment variables and contents of the agent configuration file (seeConfigInitializerandConfigBuilder).In case any
get*Property()method variant gets called for the same property more than once (e.g. each time an advice executes) it is suggested to cache the result instead of repeatedly callingConfig. 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.- Returns:
- A string property value or
defaultValueif a property with namenamedid not exist.
-
getBooleanProperty
public boolean getBooleanProperty(String name, boolean defaultValue)
Returns a boolean property value ordefaultValueif a property with namenamedid not exist.- See Also:
getProperty(String, String)
-
getListProperty
public List<String> getListProperty(String name)
Returns a list-of-strings property value or empty list if a property with namenamedid not exist.- See Also:
getProperty(String, String)
-
getListProperty
public List<String> getListProperty(String name, List<String> defaultValue)
Returns a list-of-strings property value ordefaultValueif a property with namenamedid not exist.- See Also:
getProperty(String, String)
-
getMapProperty
public Map<String,String> getMapProperty(String name)
Returns a map-of-strings property value or empty map if a property with namenamedid not exist.- See Also:
getProperty(String, String)
-
isInstrumentationEnabled
public boolean isInstrumentationEnabled(Iterable<String> instrumentationNames, boolean defaultEnabled)
-
isInstrumentationPropertyEnabled
public boolean isInstrumentationPropertyEnabled(Iterable<String> instrumentationNames, String suffix, boolean defaultEnabled)
-
asJavaProperties
public Properties asJavaProperties()
-
-