Class Config
java.lang.Object
io.opentelemetry.instrumentation.api.config.Config
Represents the global instrumentation configuration consisting of system properties and
environment variables; and, if using the OpenTelemetry javaagent, contents of the agent
configuration file and properties defined by the
ContextCustomizer 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 Config. The 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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigBuilderbuilder()Start building a newConfiginstance.static Configget()Returns the global instrumentation configuration.Returns all properties stored in thisConfiginstance.booleangetBoolean(String name, boolean defaultValue) Returns a boolean-valued configuration property ordefaultValueif a property with namenamehas not been configured.doubleReturns a double-valued configuration property ordefaultValueif a property with namenamehas not been configured or when parsing has failed.getDuration(String name, Duration defaultValue) Returns a duration-valued configuration property ordefaultValueif a property with namenamehas not been configured or when parsing has failed.intReturns an integer-valued configuration property ordefaultValueif a property with namenamehas not been configured or when parsing has failed.Returns a list-valued configuration property ordefaultValueif a property with namenamehas not been configured.longReturns a long-valued configuration property ordefaultValueif a property with namenamehas not been configured or when parsing has failed.Returns a map-valued configuration property ordefaultValueif a property with namenamehas not been configured or when parsing has failed.Returns a string-valued configuration property ornullif a property with namenamehas not been configured.Returns a string-valued configuration property ordefaultValueif a property with namenamehas not been configured.static voidinternalInitializeConfig(Config config) Sets the instrumentation configuration singleton.Returns a newConfigBuilderinstance populated with the properties of thisConfig.
-
Method Details
-
builder
Start building a newConfiginstance. -
internalInitializeConfig
Sets the instrumentation configuration singleton. This method is only supposed to be called once, during the javaagent initialization, just beforeget()is used for the first time.This method is internal and is hence not for public use. Its API is unstable and can change at any time.
-
get
Returns the global instrumentation configuration. -
getAllProperties
Returns all properties stored in thisConfiginstance. The returned map is unmodifiable. -
getString
Returns a string-valued configuration property ornullif a property with namenamehas not been configured. -
getString
Returns a string-valued configuration property ordefaultValueif a property with namenamehas not been configured. -
getBoolean
Returns a boolean-valued configuration property ordefaultValueif a property with namenamehas not been configured. -
getInt
Returns an integer-valued configuration property ordefaultValueif a property with namenamehas not been configured or when parsing has failed. -
getLong
Returns a long-valued configuration property ordefaultValueif a property with namenamehas not been configured or when parsing has failed. -
getDouble
Returns a double-valued configuration property ordefaultValueif a property with namenamehas not been configured or when parsing has failed. -
getDuration
Returns a duration-valued configuration property ordefaultValueif a property with namenamehas 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
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. The returned list is unmodifiable. -
getMap
Returns a map-valued configuration property ordefaultValueif a property with namenamehas 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. -
toBuilder
Returns a newConfigBuilderinstance populated with the properties of thisConfig.
-