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
ObservationDocumentationinterface - If the observation contains
KeyNamethen 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
KeyNameenumvalues()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 StringMore 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 StringgetName()Default technical name (e.g.: metric name).default StringReturns 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 anObservationfor the givenObservationConvention.default Observationobservation(ObservationRegistry registry) Creates anObservation.default Observationobservation(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 Observationstart(ObservationRegistry registry) Creates and starts anObservation.default Observationstart(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 theObservationRegistryis null or the no-op registry, this fast returns a no-opObservationand skips the creation of theObservation.Context. This check avoids unnecessaryObservation.Contextcreation, which is why it takes aSupplierfor 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 anObservationfor the givenObservationConvention. You need to manually start it. When theObservationRegistryis null or the no-op registry, this fast returns a no-opObservationand skips the creation of theObservation.Context. This check avoids unnecessaryObservation.Contextcreation, which is why it takes aSupplierfor 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 theObservationRegistryis null or the no-op registry, this fast returns a no-opObservationand skips the creation of theObservation.Context. This check avoids unnecessaryObservation.Contextcreation, which is why it takes aSupplierfor 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 theObservationRegistryis null or the no-op registry, this fast returns a no-opObservationand skips the creation of theObservation.Context. This check avoids unnecessaryObservation.Contextcreation, which is why it takes aSupplierfor 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
-