Class Config
- java.lang.Object
-
- io.opentelemetry.instrumentation.api.config.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 theConfigPropertySourceSPI (seeConfigInitializerandConfigBuilder).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 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.
-
-
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()Returns the global agent configuration.abstract Map<String,String>getAllProperties()Returns all properties stored in this instance.@Nullable BooleangetBoolean(String name)Returns a boolean-valued configuration property ornullif a property with namenamehas not been configured.booleangetBoolean(String name, boolean defaultValue)Returns a boolean-valued configuration property ordefaultValueif a property with namenamehas not been configured.booleangetBooleanProperty(String name, boolean defaultValue)Deprecated.UsegetBoolean(String, boolean)instead.@Nullable DoublegetDouble(String name)Returns a double-valued configuration property ornullif a property with namenamehas not been configured.doublegetDouble(String name, double defaultValue)Returns a double-valued configuration property ordefaultValueif a property with namenamehas not been configured.@Nullable DurationgetDuration(String name)Returns a duration-valued configuration property ornullif a property with namenamehas not been configured.DurationgetDuration(String name, Duration defaultValue)Returns a duration-valued configuration property ordefaultValueif a property with namenamehas not been configured.@Nullable IntegergetInt(String name)Returns a integer-valued configuration property ornullif a property with namenamehas not been configured.intgetInt(String name, int defaultValue)Returns a integer-valued configuration property ordefaultValueif a property with namenamehas not been configured.List<String>getList(String name)Returns a list-valued configuration property or an empty list if a property with namenamehas not been configured.List<String>getList(String name, List<String> defaultValue)Returns a list-valued configuration property ordefaultValueif a property with namenamehas not been configured.List<String>getListProperty(String name)Deprecated.UsegetList(String)instead.List<String>getListProperty(String name, List<String> defaultValue)Deprecated.UsegetList(String, List)instead.@Nullable LonggetLong(String name)Returns a long-valued configuration property ornullif a property with namenamehas not been configured.longgetLong(String name, long defaultValue)Returns a long-valued configuration property ordefaultValueif a property with namenamehas not been configured.Map<String,String>getMap(String name)Returns a map-valued configuration property or an empty map if a property with namenamehas not been configured.Map<String,String>getMap(String name, Map<String,String> defaultValue)Returns a map-valued configuration property ordefaultValueif a property with namenamehas not been configured.Map<String,String>getMapProperty(String name)Deprecated.UsegetMap(String, Map)instead.@Nullable StringgetProperty(String name)Deprecated.UsegetString(String)instead.StringgetProperty(String name, String defaultValue)Deprecated.UsegetString(String, String)instead.@Nullable StringgetString(String name)Returns a string-valued configuration property ornullif a property with namenamehas not been configured.StringgetString(String name, String defaultValue)Returns a string-valued configuration property ordefaultValueif a property with namenamehas not been configured.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()
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.UsegetString(String)instead.Returns a string-valued configuration property ornullif a property with namenamehas not been configured.
-
getProperty
@Deprecated public String getProperty(String name, String defaultValue)
Deprecated.UsegetString(String, String)instead.Returns a string-valued configuration property ordefaultValueif a property with namenamehas not been configured.
-
getString
public @Nullable String getString(String name)
Returns a string-valued configuration property ornullif a property with namenamehas not been configured.
-
getString
public String getString(String name, String defaultValue)
Returns a string-valued configuration property ordefaultValueif a property with namenamehas not been configured.
-
getBoolean
public @Nullable Boolean getBoolean(String name)
Returns a boolean-valued configuration property ornullif a property with namenamehas not been configured.
-
getBoolean
public boolean getBoolean(String name, boolean defaultValue)
Returns a boolean-valued configuration property ordefaultValueif a property with namenamehas not been configured.
-
getBooleanProperty
@Deprecated public boolean getBooleanProperty(String name, boolean defaultValue)
Deprecated.UsegetBoolean(String, boolean)instead.Returns a boolean-valued configuration property ordefaultValueif a property with namenamehas not been configured.
-
getInt
public @Nullable Integer getInt(String name)
Returns a integer-valued configuration property ornullif a property with namenamehas not been configured.
-
getInt
public int getInt(String name, int defaultValue)
Returns a integer-valued configuration property ordefaultValueif a property with namenamehas not been configured.
-
getLong
public @Nullable Long getLong(String name)
Returns a long-valued configuration property ornullif a property with namenamehas not been configured.
-
getLong
public long getLong(String name, long defaultValue)
Returns a long-valued configuration property ordefaultValueif a property with namenamehas not been configured.
-
getDouble
public @Nullable Double getDouble(String name)
Returns a double-valued configuration property ornullif a property with namenamehas not been configured.
-
getDouble
public double getDouble(String name, double defaultValue)
Returns a double-valued configuration property ordefaultValueif a property with namenamehas not been configured.
-
getDuration
public @Nullable Duration getDuration(String name)
Returns a duration-valued configuration property ornullif a property with namenamehas 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 ordefaultValueif a property with namenamehas 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.UsegetList(String)instead.Returns a list-valued configuration property or an empty list if a property with namenamehas 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.UsegetList(String, List)instead.Returns a list-valued configuration property ordefaultValueif a property with namenamehas 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 namenamehas 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 ordefaultValueif a property with namenamehas 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.UsegetMap(String, Map)instead.Returns a map-valued configuration property or an empty map if a property with namenamehas 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 namenamehas 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 ordefaultValueif a property with namenamehas 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()
-
asJavaProperties
@Deprecated public Properties asJavaProperties()
Deprecated.UsegetAllProperties()instead.Converts this config instance to JavaProperties.
-
-