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 Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PropertiesasJavaProperties()Deprecated.UsegetAllProperties()instead.static Configget()abstract Map<String,String>getAllProperties()Returns all properties stored in this instance.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.longgetLongProperty(String name, long defaultValue)Returns a long 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.booleanisAgentDebugEnabled()booleanisInstrumentationEnabled(Iterable<String> instrumentationNames, boolean defaultEnabled)booleanisInstrumentationPropertyEnabled(Iterable<String> instrumentationNames, String suffix, boolean defaultEnabled)static ConfigBuildernewBuilder()Start building a newConfiginstance.
-
-
-
Method Detail
-
newBuilder
public static ConfigBuilder newBuilder()
Start building a newConfiginstance.
-
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()
-
getAllProperties
public abstract Map<String,String> getAllProperties()
Returns all properties stored in this instance. The returned map is unmodifiable.
-
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)
-
getLongProperty
public long getLongProperty(String name, long defaultValue)
Returns a long property value ordefaultValueif a property with namenamedid not exist.This property may be used by vendor distributions to get numerical values.
- 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
@Deprecated public Properties asJavaProperties()
Deprecated.UsegetAllProperties()instead.Converts this config instance to JavaProperties.
-
isAgentDebugEnabled
public boolean isAgentDebugEnabled()
-
-