Class LazyMetricsRecorder
java.lang.Object
com.fayupable.logged.spring.metrics.LazyMetricsRecorder
- All Implemented Interfaces:
MetricsRecorder
MetricsRecorder that defers the choice between a real
Micrometer-backed recorder and a no-op fallback to the first actual
invocation, instead of to Spring Boot auto-configuration ordering.
Whether a MeterRegistry bean exists at a given point during
context refresh depends on the order in which Spring Boot processes
auto-configurations, an order this module cannot reliably pin itself
against across Spring Boot versions. Resolving lazily through
ObjectProvider, on the other hand, is unaffected by that
ordering: by the time any @Logged method is actually invoked,
the application context has fully started, and any MeterRegistry
bean that is ever going to exist already does.
-
Constructor Summary
ConstructorsConstructorDescriptionLazyMetricsRecorder(org.springframework.beans.factory.ObjectProvider<io.micrometer.core.instrument.MeterRegistry> meterRegistryProvider) -
Method Summary
-
Constructor Details
-
LazyMetricsRecorder
public LazyMetricsRecorder(org.springframework.beans.factory.ObjectProvider<io.micrometer.core.instrument.MeterRegistry> meterRegistryProvider)
-
-
Method Details
-
record
public void record(String className, String methodName, long durationNanos, boolean success, String exceptionType) Description copied from interface:MetricsRecorderRecords the outcome and duration of a single method invocation.- Specified by:
recordin interfaceMetricsRecorder- Parameters:
className- the simple or fully qualified name of the class declaring the invoked methodmethodName- the name of the invoked methoddurationNanos- the wall-clock duration of the invocation, in nanosecondssuccess-trueif the method returned normally,falseif it threw an exceptionexceptionType- the simple class name of the exception thrown by the method, ornullif the call succeeded
-