Class CrossModuleEventCounterFactory
java.lang.Object
org.springframework.modulith.observability.support.CrossModuleEventCounterFactory
- All Implemented Interfaces:
ModulithEventMetrics
A factory to create
Counter.Builder
instances for Counter
s eventually. Target for dependency injection via
the ModulithEventMetricsCustomizer
interface to allow users to
augment the counters with additional information.- Since:
- 1.4
- Author:
- Oliver Drotbohm, Marcin Grzejszczak
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) io.micrometer.core.instrument.Counter.Builder
createCounterBuilder
(Object event) Creates aCounter.Builder
instance for the given event applying registered customizers.customize
(Class<T> type, BiConsumer<T, io.micrometer.core.instrument.Counter.Builder> consumer) Customizes aCounter.Builder
to eventually produce aCounter
for the event of the given type.Customizes the creation of aCounter.Builder
for events of the given type.
-
Constructor Details
-
CrossModuleEventCounterFactory
public CrossModuleEventCounterFactory()
-
-
Method Details
-
createCounterBuilder
Creates aCounter.Builder
instance for the given event applying registered customizers.- Parameters:
event
- must not be null.- Returns:
- will never be null.
-
customize
public <T> ModulithEventMetrics customize(Class<T> type, Function<T, io.micrometer.core.instrument.Counter.Builder> factory) Description copied from interface:ModulithEventMetrics
Customizes the creation of aCounter.Builder
for events of the given type. The instances created will still be subject to customizations registered viaModulithEventMetrics.customize(Class, BiConsumer)
.- Specified by:
customize
in interfaceModulithEventMetrics
- Parameters:
type
- must not be null.factory
- must not be null.- Returns:
- will never be null.
-
customize
public <T> CrossModuleEventCounterFactory customize(Class<T> type, BiConsumer<T, io.micrometer.core.instrument.Counter.Builder> consumer) Description copied from interface:ModulithEventMetrics
Customizes aCounter.Builder
to eventually produce aCounter
for the event of the given type. TheCounter.Builder
will have been set up named after the fully-qualified type name. To customize the creation, also callModulithEventMetrics.customize(Class, Function)
.- Specified by:
customize
in interfaceModulithEventMetrics
- Type Parameters:
T
- the type of the event.- Parameters:
type
- must not be null.consumer
- must not be null.- Returns:
- will never be null.
- See Also:
-