Skip to content

Commit aba85b3

Browse files
sideeffffectjonatan-ivanov
authored andcommitted
More constructors for KafkaClientMetrics
Signed-off-by: Ondra Pelech <[email protected]>
1 parent d981559 commit aba85b3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

micrometer-core/src/main/java/io/micrometer/core/instrument/binder/kafka/KafkaClientMetrics.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
import org.apache.kafka.clients.consumer.Consumer;
2424
import org.apache.kafka.clients.producer.Producer;
2525
import org.apache.kafka.common.Metric;
26+
import org.apache.kafka.common.MetricName;
2627

2728
import java.time.Duration;
29+
import java.util.Map;
2830
import java.util.concurrent.ScheduledExecutorService;
31+
import java.util.function.Supplier;
2932

3033
/**
3134
* Kafka Client metrics binder. This should be closed on application shutdown to clean up
@@ -223,4 +226,38 @@ public KafkaClientMetrics(AdminClient adminClient) {
223226
super(adminClient::metrics);
224227
}
225228

229+
/**
230+
* Kafka client metrics binder
231+
* @param metricsSupplier supplier of metrics, make sure this comes from the Java
232+
* Kafka Client because {@link KafkaClientMetrics} heavily depends on the behavior of
233+
* the Java Kafka Client
234+
*/
235+
public KafkaClientMetrics(Supplier<Map<MetricName, ? extends Metric>> metricsSupplier) {
236+
super(metricsSupplier);
237+
}
238+
239+
/**
240+
* Kafka client metrics binder
241+
* @param metricsSupplier supplier of metrics, make sure this comes from the Java
242+
* Kafka Client because {@link KafkaClientMetrics} heavily depends on the behavior of
243+
* the Java Kafka Client
244+
* @param tags additional tags
245+
*/
246+
public KafkaClientMetrics(Supplier<Map<MetricName, ? extends Metric>> metricsSupplier, Iterable<Tag> tags) {
247+
super(metricsSupplier, tags);
248+
}
249+
250+
/**
251+
* Kafka client metrics binder
252+
* @param metricsSupplier supplier of metrics, make sure this comes from the Java
253+
* Kafka Client because {@link KafkaClientMetrics} heavily depends on the behavior of
254+
* the Java Kafka Client
255+
* @param tags additional tags
256+
* @param scheduler custom scheduler to check and bind metrics
257+
*/
258+
public KafkaClientMetrics(Supplier<Map<MetricName, ? extends Metric>> metricsSupplier, Iterable<Tag> tags,
259+
ScheduledExecutorService scheduler) {
260+
super(metricsSupplier, tags, scheduler);
261+
}
262+
226263
}

0 commit comments

Comments
 (0)