Package org.springframework.kafka.core
Class KafkaMetricsSupport<C>
java.lang.Object
org.springframework.kafka.core.KafkaMetricsSupport<C>
- Type Parameters:
C
- the Kafka Client type.
- Direct Known Subclasses:
KafkaStreamsMicrometerListener
,MicrometerConsumerListener
,MicrometerProducerListener
An abstract class to manage
KafkaClientMetrics
.- Since:
- 3.3
- Author:
- Artem Bilan
- See Also:
-
KafkaClientMetrics
-
Field Summary
Modifier and TypeFieldDescriptionprotected final io.micrometer.core.instrument.MeterRegistry
protected final ScheduledExecutorService
protected final List<io.micrometer.core.instrument.Tag>
-
Constructor Summary
ModifierConstructorDescriptionprotected
KafkaMetricsSupport
(io.micrometer.core.instrument.MeterRegistry meterRegistry) Construct an instance with the provided registry.protected
KafkaMetricsSupport
(io.micrometer.core.instrument.MeterRegistry meterRegistry, List<io.micrometer.core.instrument.Tag> tags) Construct an instance with the providedMeterRegistry
and tags.protected
KafkaMetricsSupport
(io.micrometer.core.instrument.MeterRegistry meterRegistry, List<io.micrometer.core.instrument.Tag> tags, TaskScheduler taskScheduler) Construct an instance with the providedMeterRegistry
, tags andTaskScheduler
.protected
KafkaMetricsSupport
(io.micrometer.core.instrument.MeterRegistry meterRegistry, TaskScheduler taskScheduler) Construct an instance with the providedMeterRegistry
andTaskScheduler
. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
bindClient
(String id, C client) Bind metrics for the Apache Kafka client with provided id.protected io.micrometer.core.instrument.binder.MeterBinder
createClientMetrics
(C client, List<io.micrometer.core.instrument.Tag> tags) Create aio.micrometer.core.instrument.binder.kafka.KafkaMetrics
instance for the provided Kafka client and metric tags.protected final void
unbindClient
(String id, C client) Unbind aio.micrometer.core.instrument.binder.kafka.KafkaMetrics
for the provided Kafka client.
-
Field Details
-
meterRegistry
protected final io.micrometer.core.instrument.MeterRegistry meterRegistry -
tags
-
scheduler
-
-
Constructor Details
-
KafkaMetricsSupport
protected KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry) Construct an instance with the provided registry.- Parameters:
meterRegistry
- the registry.
-
KafkaMetricsSupport
protected KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry, TaskScheduler taskScheduler) Construct an instance with the providedMeterRegistry
andTaskScheduler
.- Parameters:
meterRegistry
- the registry.taskScheduler
- the task scheduler.
-
KafkaMetricsSupport
protected KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry, List<io.micrometer.core.instrument.Tag> tags) Construct an instance with the providedMeterRegistry
and tags.- Parameters:
meterRegistry
- the registry.tags
- the tags.
-
KafkaMetricsSupport
protected KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry, List<io.micrometer.core.instrument.Tag> tags, TaskScheduler taskScheduler) Construct an instance with the providedMeterRegistry
, tags andTaskScheduler
.- Parameters:
meterRegistry
- the registry.tags
- the tags.taskScheduler
- the task scheduler.
-
-
Method Details
-
bindClient
Bind metrics for the Apache Kafka client with provided id.- Parameters:
id
- the unique identifier for the client to manage in store.client
- the Kafka client instance to bind.
-
createClientMetrics
protected io.micrometer.core.instrument.binder.MeterBinder createClientMetrics(C client, List<io.micrometer.core.instrument.Tag> tags) Create aio.micrometer.core.instrument.binder.kafka.KafkaMetrics
instance for the provided Kafka client and metric tags. By default, this factory is aware ofConsumer
,Producer
andAdminClient
types. For other use-case this method can be overridden.- Parameters:
client
- the client to create aio.micrometer.core.instrument.binder.kafka.KafkaMetrics
instance for.tags
- the tags for theio.micrometer.core.instrument.binder.kafka.KafkaMetrics
.- Returns:
- the
io.micrometer.core.instrument.binder.kafka.KafkaMetrics
.
-
unbindClient
Unbind aio.micrometer.core.instrument.binder.kafka.KafkaMetrics
for the provided Kafka client.- Parameters:
id
- the unique identifier for the client to manage in store.client
- the Kafka client instance to unbind.
-