MetricCommandBus

Metric decorator for command buses that collects metrics on command sending and receiving operations. This class wraps any CommandBus implementation and adds metrics collection with tags for aggregate name, command name, and source identification.

Parameters

T

the specific type of CommandBus being decorated

Inheritors

Constructors

Link copied to clipboard
constructor(delegate: T)

Properties

Link copied to clipboard
override val delegate: T

the original component being decorated, must implement the Decorator interface

Link copied to clipboard

The source identifier derived from the original delegate's class name. This is used for metrics tagging to identify the component type.

Link copied to clipboard
open override val topicKind: TopicKind

The topic kind for command messages, always returns TopicKind.COMMAND

Functions

Link copied to clipboard
open override fun close()

Closes the command bus and releases any resources. This delegates to the underlying command bus implementation.

Link copied to clipboard
open override fun receive(namedAggregates: Set<NamedAggregate>): Flux<ServerCommandExchange<*>>

Receives command exchanges for the specified named aggregates and collects metrics on the operation. Metrics collected include timing and tags for aggregate identification and subscriber information.

Link copied to clipboard
open override fun send(message: CommandMessage<*>): Mono<Void>

Sends a command message and collects metrics on the operation. Metrics collected include timing, success/failure rates, and tags for aggregate and command identification.

Link copied to clipboard
fun <M> Flux<M>.tagSource(): Flux<M>

Extension function to tag a Flux publisher with the current source identifier. This adds the source tag to metrics collected from this reactive stream.

fun <M> Mono<M>.tagSource(): Mono<M>

Extension function to tag a Mono publisher with the current source identifier. This adds the source tag to metrics collected from this reactive stream.