Package io.micrometer.observation.docs
Interface ObservationDocumentation
public interface ObservationDocumentation
In order to describe your samples via e.g. enums instead of Strings you can use this
interface that returns all the characteristics of a sample. We can analyze the sources
and reuse this information to build a table of known metrics, their names and tags.
We can generate documentation for all created samples but certain requirements need to
be met.
- Observations are grouped within an enum - the enum implements the
ObservationDocumentation
interface - If the observation contains
KeyName
then those need to be declared as nested enums - The
getHighCardinalityKeyNames()
need to call the nested enum'svalues()
method to retrieve the array of allowed keys - The
getLowCardinalityKeyNames()
need to call the nested enum'svalues()
method to retrieve the array of allowed keys - Javadocs around enums will be used as description
- If you want to merge different
KeyName
enumvalues()
methods you need to call theKeyName.merge(KeyName[]...)
method
- Since:
- 1.10.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.micrometer.common.docs.KeyName[]
Empty key names.static final Observation.Event[]
Empty event names. -
Method Summary
Modifier and TypeMethodDescriptiondefault String
More human-readable name available within the given context (e.g.: span name).default Class
<? extends ObservationConvention<? extends Observation.Context>> Default naming convention (sets technical and contextual names, and key values).default Observation.Event[]
Event values.default io.micrometer.common.docs.KeyName[]
High cardinality key names.default io.micrometer.common.docs.KeyName[]
Low cardinality key names.default String
getName()
Default technical name (e.g.: metric name).default String
Returns required prefix to be there for tags.default <T extends Observation.Context>
Observationobservation
(ObservationConvention<T> customConvention, ObservationConvention<T> defaultConvention, Supplier<T> contextSupplier, ObservationRegistry registry) Creates anObservation
for the givenObservationConvention
.default Observation
observation
(ObservationRegistry registry) Creates anObservation
.default Observation
observation
(ObservationRegistry registry, Supplier<Observation.Context> contextSupplier) Creates anObservation
.default <T extends Observation.Context>
Observationstart
(ObservationConvention<T> customConvention, ObservationConvention<T> defaultConvention, Supplier<T> contextSupplier, ObservationRegistry registry) Creates and starts anObservation
.default Observation
start
(ObservationRegistry registry) Creates and starts anObservation
.default Observation
start
(ObservationRegistry registry, Supplier<Observation.Context> contextSupplier) Creates and starts anObservation
.
-
Field Details
-
EMPTY
static final io.micrometer.common.docs.KeyName[] EMPTYEmpty key names. -
EMPTY_EVENT_NAMES
Empty event names.
-
-
Method Details
-
getName
Default technical name (e.g.: metric name). You can set the name either by this method orgetDefaultConvention()
. You can't use both.- Returns:
- name
-
getDefaultConvention
@Nullable default Class<? extends ObservationConvention<? extends Observation.Context>> getDefaultConvention()Default naming convention (sets technical and contextual names, and key values). You can set the names either by this method orgetName()
andgetContextualName()
.- Returns:
- default naming convention
-
getContextualName
More human-readable name available within the given context (e.g.: span name). You can set the name either by this method orgetDefaultConvention()
. This method will override whatgetDefaultConvention()
has set.- Returns:
- contextual name
-
getLowCardinalityKeyNames
default io.micrometer.common.docs.KeyName[] getLowCardinalityKeyNames()Low cardinality key names.- Returns:
- allowed tag keys for low cardinality key-values
-
getHighCardinalityKeyNames
default io.micrometer.common.docs.KeyName[] getHighCardinalityKeyNames()High cardinality key names.- Returns:
- allowed tag keys for high cardinality key-values
-
getEvents
Event values.- Returns:
- allowed event values
-
getPrefix
Returns required prefix to be there for tags. For example,foo.
would require the tags to have afoo.
prefix like this:foo.bar=true
.- Returns:
- required prefix
-
observation
Creates anObservation
. You need to manually start it.- Parameters:
registry
- observation registry- Returns:
- observation
-
observation
default Observation observation(ObservationRegistry registry, Supplier<Observation.Context> contextSupplier) Creates anObservation
. You need to manually start it. When theObservationRegistry
is null or the no-op registry, this fast returns a no-opObservation
and skips the creation of theObservation.Context
. This check avoids unnecessaryObservation.Context
creation, which is why it takes aSupplier
for the context rather than the context directly. If the observation is not enabled by anObservationPredicate
, a no-op observation will also be returned.- Parameters:
registry
- observation registrycontextSupplier
- observation context supplier- Returns:
- observation
-
observation
default <T extends Observation.Context> Observation observation(@Nullable ObservationConvention<T> customConvention, ObservationConvention<T> defaultConvention, Supplier<T> contextSupplier, ObservationRegistry registry) Creates anObservation
for the givenObservationConvention
. You need to manually start it. When theObservationRegistry
is null or the no-op registry, this fast returns a no-opObservation
and skips the creation of theObservation.Context
. This check avoids unnecessaryObservation.Context
creation, which is why it takes aSupplier
for the context rather than the context directly. If the observation is not enabled by anObservationPredicate
, a no-op observation will also be returned.- Parameters:
customConvention
- convention that (if notnull
) will override any pre-configured conventionsdefaultConvention
- default convention that will be picked if there was neither custom convention nor a pre-configured one viaObservationRegistry.ObservationConfig.observationConvention(GlobalObservationConvention)
contextSupplier
- observation context supplierregistry
- observation registry- Returns:
- observation
-
start
Creates and starts anObservation
.- Parameters:
registry
- observation registry- Returns:
- observation
-
start
default Observation start(ObservationRegistry registry, Supplier<Observation.Context> contextSupplier) Creates and starts anObservation
. When theObservationRegistry
is null or the no-op registry, this fast returns a no-opObservation
and skips the creation of theObservation.Context
. This check avoids unnecessaryObservation.Context
creation, which is why it takes aSupplier
for the context rather than the context directly. If the observation is not enabled by anObservationPredicate
, a no-op observation will also be returned.- Parameters:
registry
- observation registrycontextSupplier
- observation context supplier- Returns:
- observation
-
start
default <T extends Observation.Context> Observation start(@Nullable ObservationConvention<T> customConvention, ObservationConvention<T> defaultConvention, Supplier<T> contextSupplier, ObservationRegistry registry) Creates and starts anObservation
. When theObservationRegistry
is null or the no-op registry, this fast returns a no-opObservation
and skips the creation of theObservation.Context
. This check avoids unnecessaryObservation.Context
creation, which is why it takes aSupplier
for the context rather than the context directly. If the observation is not enabled by anObservationPredicate
, a no-op observation will also be returned.- Parameters:
customConvention
- convention that (if notnull
) will override any pre-configured conventionsdefaultConvention
- default convention that will be picked if there was neither custom convention nor a pre-configured one viaObservationRegistry.ObservationConfig.observationConvention(GlobalObservationConvention)
contextSupplier
- observation context supplierregistry
- observation registry- Returns:
- observation
-