Top Description Inners Fields Methods
io.micrometer.observation

public Interface ObservationRegistry

Known Direct Implementers
io.micrometer.observation.SimpleObservationRegistry, io.micrometer.observation.NoopObservationRegistry
Imports
io.micrometer.common.lang.Nullable, java.util.Collection, .List, .Objects, java.util.concurrent.CopyOnWriteArrayList, java.util.function.Supplier

Implementations of this interface are responsible for managing state of an Observation.
Authors
Jonatan Ivanov, Tommy Ludwig, Marcin Grzejszczak
Since
1.10.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ObservationRegistry.ObservationConfig

Access to configuration options for this registry.

Field Summary

Modifier and TypeField and Description
public static final ObservationRegistry
NOOP

No-op implementation of ObservationRegistry.

Method Summary

Modifier and TypeMethod and Description
public static ObservationRegistry

Returns:

ObservationRegistry instance
create
()

Creates an instance of ObservationRegistry.

public Observation

Returns:

current observation or null if it's not present
getCurrentObservation
()

When previously set will allow to retrieve the Observation at any point in time.

public Observation.Scope

Returns:

current observation scope or null if it's not present
getCurrentObservationScope
()

When previously set will allow to retrieve the Observation.

public default boolean

Returns:

true when this is a no-op observation registry
isNoop
()

Checks whether this ObservationRegistry is no-op.

public ObservationRegistry.ObservationConfig

Returns:

observation configuration
observationConfig
()

Configuration options for this registry.

public void
setCurrentObservationScope(Observation.Scope
observation scope
current
)

Sets the observation scope as current.

Field Detail

NOOPback to summary
public static final ObservationRegistry NOOP

No-op implementation of ObservationRegistry.

Method Detail

createback to summary
public static ObservationRegistry create()

Creates an instance of ObservationRegistry.

Returns:ObservationRegistry

ObservationRegistry instance

getCurrentObservationback to summary
public Observation getCurrentObservation()

When previously set will allow to retrieve the Observation at any point in time. Example: if an Observation was put in Observation.Scope then this method will return the current present Observation within the scope.

Returns:Observation

current observation or null if it's not present

Annotations
@Nullable
getCurrentObservationScopeback to summary
public Observation.Scope getCurrentObservationScope()

When previously set will allow to retrieve the Observation.Scope at any point in time. Example: if an Observation was put in Observation.Scope then this method will return the current present Observation.Scope.

Returns:Observation.Scope

current observation scope or null if it's not present

Annotations
@Nullable
isNoopback to summary
public default boolean isNoop()

Checks whether this ObservationRegistry is no-op.

Returns:boolean

true when this is a no-op observation registry

observationConfigback to summary
public ObservationRegistry.ObservationConfig observationConfig()

Configuration options for this registry.

Returns:ObservationRegistry.ObservationConfig

observation configuration

setCurrentObservationScopeback to summary
public void setCurrentObservationScope(Observation.Scope current)

Sets the observation scope as current.

Parameters
current:Observation.Scope

observation scope

io.micrometer.observation back to summary

public Class ObservationRegistry.ObservationConfig

extends Object
Class Inheritance
  • java.lang.Object
  • io.micrometer.observation.ObservationRegistry.ObservationConfig
Known Direct Subclasses
io.micrometer.observation.NoopObservationConfig

Access to configuration options for this registry.

Field Summary

Modifier and TypeField and Description
private final List<ObservationConvention<?>>
private final List<ObservationFilter>
private final List<ObservationHandler<?>>
private final List<ObservationPredicate>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv <T extends Observation.Context> ObservationConvention<T>

Returns:

matching ObservationConvention or default when no matching found
getObservationConvention
(T
context
context
,
ObservationConvention<T>
default convention if none found
defaultConvention
)

Finds an ObservationConvention for the given Observation.

pack-priv Collection<ObservationConvention<?>>
pack-priv Collection<ObservationFilter>
pack-priv Collection<ObservationHandler<?>>
pack-priv boolean

Returns:

true when observation is enabled
isObservationEnabled
(String
observation technical name
name
,
Observation.Context
context
context
)

Check to assert whether Observation should be created or NoopObservation instead.

public ObservationRegistry.ObservationConfig

Returns:

This configuration instance
observationConvention
(GlobalObservationConvention<?>
observation convention
observationConvention
)

Register an ObservationConvention.

public ObservationRegistry.ObservationConfig

Returns:

This configuration instance
observationFilter
(ObservationFilter
an observation filter to add to the current configuration
observationFilter
)

Register an observation filter for the observations.

public ObservationRegistry.ObservationConfig

Returns:

This configuration instance
observationHandler
(ObservationHandler<?>
handler to add to the current configuration
handler
)

Register a handler for the observations.

public ObservationRegistry.ObservationConfig

Returns:

This configuration instance
observationPredicate
(ObservationPredicate
predicate
predicate
)

Register a predicate to define whether observation should be created or a NoopObservation instead.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

observationConventionsback to summary
private final List<ObservationConvention<?>> observationConventions
observationFiltersback to summary
private final List<ObservationFilter> observationFilters
observationHandlersback to summary
private final List<ObservationHandler<?>> observationHandlers
observationPredicatesback to summary
private final List<ObservationPredicate> observationPredicates

Constructor Detail

ObservationConfigback to summary
public ObservationConfig()

Method Detail

getObservationConventionback to summary
pack-priv <T extends Observation.Context> ObservationConvention<T> getObservationConvention(T context, ObservationConvention<T> defaultConvention)

Finds an ObservationConvention for the given Observation.Context.

Parameters
context:T

context

defaultConvention:ObservationConvention<T>

default convention if none found

Returns:ObservationConvention<T>

matching ObservationConvention or default when no matching found

Annotations
@SuppressWarnings:unchecked
getObservationConventionsback to summary
pack-priv Collection<ObservationConvention<?>> getObservationConventions()
getObservationFiltersback to summary
pack-priv Collection<ObservationFilter> getObservationFilters()
getObservationHandlersback to summary
pack-priv Collection<ObservationHandler<?>> getObservationHandlers()
isObservationEnabledback to summary
pack-priv boolean isObservationEnabled(String name, Observation.Context context)

Check to assert whether Observation should be created or NoopObservation instead.

Parameters
name:String

observation technical name

context:Observation.Context

context

Returns:boolean

true when observation is enabled

observationConventionback to summary
public ObservationRegistry.ObservationConfig observationConvention(GlobalObservationConvention<?> observationConvention)

Register an ObservationConvention.

Please check the javadoc of Observation#createNotStarted(ObservationConvention, ObservationConvention, Supplier, ObservationRegistry) method for the logic of choosing the convention.

Parameters
observationConvention:GlobalObservationConvention<?>

observation convention

Returns:ObservationRegistry.ObservationConfig

This configuration instance

observationFilterback to summary
public ObservationRegistry.ObservationConfig observationFilter(ObservationFilter observationFilter)

Register an observation filter for the observations.

Parameters
observationFilter:ObservationFilter

an observation filter to add to the current configuration

Returns:ObservationRegistry.ObservationConfig

This configuration instance

observationHandlerback to summary
public ObservationRegistry.ObservationConfig observationHandler(ObservationHandler<?> handler)

Register a handler for the observations.

Parameters
handler:ObservationHandler<?>

handler to add to the current configuration

Returns:ObservationRegistry.ObservationConfig

This configuration instance

observationPredicateback to summary
public ObservationRegistry.ObservationConfig observationPredicate(ObservationPredicate predicate)

Register a predicate to define whether observation should be created or a NoopObservation instead.

Parameters
predicate:ObservationPredicate

predicate

Returns:ObservationRegistry.ObservationConfig

This configuration instance