Class CrossModuleEventCounterFactory
java.lang.Object
org.springframework.modulith.observability.support.CrossModuleEventCounterFactory
- All Implemented Interfaces:
ModulithEventMetrics
A factory to create
Counter.Builder instances for Counters 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.BuildercreateCounterBuilder(Object event) Creates aCounter.Builderinstance for the given event applying registered customizers.customize(Class<T> type, BiConsumer<T, io.micrometer.core.instrument.Counter.Builder> consumer) Customizes aCounter.Builderto eventually produce aCounterfor the event of the given type.Customizes the creation of aCounter.Builderfor events of the given type.
-
Constructor Details
-
CrossModuleEventCounterFactory
public CrossModuleEventCounterFactory()
-
-
Method Details
-
createCounterBuilder
Creates aCounter.Builderinstance 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:ModulithEventMetricsCustomizes the creation of aCounter.Builderfor events of the given type. The instances created will still be subject to customizations registered viaModulithEventMetrics.customize(Class, BiConsumer).- Specified by:
customizein 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:ModulithEventMetricsCustomizes aCounter.Builderto eventually produce aCounterfor the event of the given type. TheCounter.Builderwill have been set up named after the fully-qualified type name. To customize the creation, also callModulithEventMetrics.customize(Class, Function).- Specified by:
customizein 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:
-