Class MeasurementTaker
java.lang.Object
dk.cloudcreate.essentials.shared.measurement.MeasurementTaker
A facade to record the execution time of a given code block using one or more
MeasurementRecorder instances.
Example of fluent usage:
return measurementTaker.context("essentials.eventstore.append_to_stream")
.description("Time taken to append events to the event store")
.tag("aggregateType", operation.getAggregateType())
.record(chain::proceed);
or
measurementTaker.recordTime(MeasurementContext.builder("essentials.invocation")
.description("Time it takes to invoke a method")
.tag("class", FunctionalInterfaceLoggingNameResolver.resolveLoggingName(invokeMethodsOn))
.tag("method", methodLoggingName)
.build(),
duration);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFluent builder for constructing a MeasurementTaker.static classA fluent builder for constructing a measurement context and recording its execution. -
Method Summary
Modifier and TypeMethodDescriptionstatic MeasurementTaker.Builderbuilder()Creates a new Builder for constructing a MeasurementTaker.Starts a fluent measurement configuration for the specified metric.<T> Trecord(MeasurementContext context, Supplier<T> block) Executes the supplied block of code, measures its execution time, and notifies all configured recorders.voidrecordTime(MeasurementContext context, Duration elapsed) Records an already measured duration.
-
Method Details
-
builder
Creates a new Builder for constructing a MeasurementTaker.- Returns:
- a new Builder instance
-
context
Starts a fluent measurement configuration for the specified metric.- Parameters:
metricName- the name of the metric- Returns:
- a fluent context builder for further configuration
-