Class DefaultMeterObservationHandler
- All Implemented Interfaces:
MeterObservationHandler<io.micrometer.observation.Observation.Context>, io.micrometer.observation.ObservationHandler<io.micrometer.observation.Observation.Context>
Timer.Sample and Counter.
Use builder(MeterRegistry) to create an instance. The builder does
not create the active observation LongTaskTimer (named
<observation-name>.active); opt in to it with
DefaultMeterObservationHandler.Builder.includeActiveObservationLongTaskTimer(boolean). The deprecated
constructors always create it.
This class is not designed for extension. To customize behavior, implement
MeterObservationHandler and delegate to an instance created by
builder(MeterRegistry); every ObservationHandler lifecycle method has
a no-op default, so only the methods you care about need to be delegated.
WARNING: When the active observation LongTaskTimer is included: since it needs
to be created in the onStart method, it can only contain tags that are
available by that time. This means that if you add a lowCardinalityKeyValue
after calling start on the Observation, that KeyValue will not
be translated as a Tag on the LongTaskTimer. Likewise, since the
KeyValuesProvider is evaluated in the stop method of the
Observation (after start), those KeyValue instances will not be used
for the LongTaskTimer.
- Since:
- 1.10.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder forDefaultMeterObservationHandler.static enumDeprecated.since 1.18.0 with no direct replacement.Nested classes/interfaces inherited from interface io.micrometer.observation.ObservationHandler
io.micrometer.observation.ObservationHandler.AllMatchingCompositeObservationHandler, io.micrometer.observation.ObservationHandler.CompositeObservationHandler, io.micrometer.observation.ObservationHandler.FirstMatchingCompositeObservationHandler -
Constructor Summary
ConstructorsConstructorDescriptionDefaultMeterObservationHandler(MeterRegistry meterRegistry) Deprecated.since 1.18.0, usebuilder(MeterRegistry)instead.DefaultMeterObservationHandler(MeterRegistry meterRegistry, DefaultMeterObservationHandler.IgnoredMeters... metersToIgnore) Deprecated.since 1.18.0, usebuilder(MeterRegistry)andDefaultMeterObservationHandler.Builder.includeActiveObservationLongTaskTimer(boolean)instead. -
Method Summary
Modifier and TypeMethodDescriptionbuilder(MeterRegistry meterRegistry) Returns aDefaultMeterObservationHandler.Builderfor aDefaultMeterObservationHandler.voidonEvent(io.micrometer.observation.Observation.Event event, io.micrometer.observation.Observation.Context context) voidonStart(io.micrometer.observation.Observation.Context context) voidonStop(io.micrometer.observation.Observation.Context context) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MeterObservationHandler
supportsContextMethods inherited from interface io.micrometer.observation.ObservationHandler
onError, onScopeClosed, onScopeOpened, onScopeReset
-
Constructor Details
-
DefaultMeterObservationHandler
Deprecated.since 1.18.0, usebuilder(MeterRegistry)instead. Beware that this constructor creates aLongTaskTimernamed<observation-name>.activein addition to theTimer, butbuilder(meterRegistry).build()does not. Usebuilder(meterRegistry).includeActiveObservationLongTaskTimer(true).build()to keep the behavior of this constructor.Creates the handler with the default configuration.- Parameters:
meterRegistry- the MeterRegistry to use
-
DefaultMeterObservationHandler
@Deprecated public DefaultMeterObservationHandler(MeterRegistry meterRegistry, DefaultMeterObservationHandler.IgnoredMeters... metersToIgnore) Deprecated.since 1.18.0, usebuilder(MeterRegistry)andDefaultMeterObservationHandler.Builder.includeActiveObservationLongTaskTimer(boolean)instead. Opting out by meter type does not scale as meters are added and cannot express a different default.new DefaultMeterObservationHandler(registry)maps tobuilder(registry).includeActiveObservationLongTaskTimer(true).build(), andnew DefaultMeterObservationHandler(registry, IgnoredMeters.LONG_TASK_TIMER)maps tobuilder(registry).build().Creates the handler with the defined IgnoredMeters to use when the handler processes the Observations.- Parameters:
meterRegistry- the MeterRegistry to usemetersToIgnore- the Meters that should not be created when Observations are handled- Since:
- 1.13.0
-
-
Method Details
-
builder
Returns aDefaultMeterObservationHandler.Builderfor aDefaultMeterObservationHandler. The returned builder does not create the active observationLongTaskTimer(named<observation-name>.active) unlessDefaultMeterObservationHandler.Builder.includeActiveObservationLongTaskTimer(boolean)is set totrue. This differs from the deprecated constructors, which create it unlessDefaultMeterObservationHandler.IgnoredMeters.LONG_TASK_TIMERis passed.- Parameters:
meterRegistry- the MeterRegistry in which to register meters- Returns:
- a new builder
- Since:
- 1.18.0
-
onStart
public void onStart(io.micrometer.observation.Observation.Context context) - Specified by:
onStartin interfaceio.micrometer.observation.ObservationHandler<io.micrometer.observation.Observation.Context>
-
onStop
public void onStop(io.micrometer.observation.Observation.Context context) - Specified by:
onStopin interfaceio.micrometer.observation.ObservationHandler<io.micrometer.observation.Observation.Context>
-
onEvent
public void onEvent(io.micrometer.observation.Observation.Event event, io.micrometer.observation.Observation.Context context) - Specified by:
onEventin interfaceio.micrometer.observation.ObservationHandler<io.micrometer.observation.Observation.Context>
-