Skip to content

Commit 3e76b08

Browse files
committed
More constructors for KafkaClientMetrics
1 parent 00be9a4 commit 3e76b08

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
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

28+
import java.util.Map;
2729
import java.util.concurrent.ScheduledExecutorService;
30+
import java.util.function.Supplier;
2831

2932
/**
3033
* Kafka Client metrics binder. This should be closed on application shutdown to clean up
@@ -141,4 +144,31 @@ public KafkaClientMetrics(AdminClient adminClient) {
141144
super(adminClient::metrics);
142145
}
143146

147+
148+
/**
149+
* Kafka client metrics binder
150+
* @param metricsSupplier supplier of metrics, make sure this comes from the Java Kafka Client because {@link KafkaClientMetrics} heavily depends on the behavior of the Java Kafka Client
151+
*/
152+
public KafkaClientMetrics(Supplier<Map<MetricName, ? extends Metric>> metricsSupplier) {
153+
super(metricsSupplier);
154+
}
155+
156+
/**
157+
* Kafka client metrics binder
158+
* @param metricsSupplier supplier of metrics, make sure this comes from the Java Kafka Client because {@link KafkaClientMetrics} heavily depends on the behavior of the Java Kafka Client
159+
* @param tags additional tags
160+
*/
161+
public KafkaClientMetrics(Supplier<Map<MetricName, ? extends Metric>> metricsSupplier, Iterable<Tag> tags) {
162+
super(metricsSupplier, tags);
163+
}
164+
165+
/**
166+
* Kafka client metrics binder
167+
* @param metricsSupplier supplier of metrics, make sure this comes from the Java Kafka Client because {@link KafkaClientMetrics} heavily depends on the behavior of the Java Kafka Client
168+
* @param tags additional tags
169+
* @param scheduler custom scheduler to check and bind metrics
170+
*/
171+
public KafkaClientMetrics(Supplier<Map<MetricName, ? extends Metric>> metricsSupplier, Iterable<Tag> tags, ScheduledExecutorService scheduler) {
172+
super(metricsSupplier, tags, scheduler);
173+
}
144174
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
@Incubating(since = "1.4.0")
5757
@NonNullApi
5858
@NonNullFields
59-
public class KafkaMetrics implements MeterBinder, AutoCloseable {
59+
class KafkaMetrics implements MeterBinder, AutoCloseable {
6060

6161
private static final InternalLogger log = InternalLoggerFactory.getInstance(KafkaMetrics.class);
6262

0 commit comments

Comments
 (0)