Skip to content

Commit 59584ed

Browse files
iliaxiliax
andauthored
BE: Add a common prefix for all app metrics (#4177)
Co-authored-by: iliax <[email protected]>
1 parent bbb739a commit 59584ed

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

kafka-ui-api/src/main/java/com/provectus/kafka/ui/util/ApplicationMetrics.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
@RequiredArgsConstructor(access = PRIVATE)
1919
public class ApplicationMetrics {
2020

21+
// kafka-ui specific metrics prefix. Added to make it easier to distinguish kui metrics from
22+
// other metrics, exposed by spring boot (like http stats, jvm, etc.)
23+
private static final String COMMON_PREFIX = "kui_";
24+
2125
private final String clusterName;
2226
private final MeterRegistry registry;
2327

@@ -40,39 +44,39 @@ public void meterPolledRecords(String topic, PolledRecords polled, boolean throt
4044
}
4145

4246
private Counter polledRecords(String topic) {
43-
return Counter.builder("topic_records_polled")
47+
return Counter.builder(COMMON_PREFIX + "topic_records_polled")
4448
.description("Number of records polled from topic")
4549
.tag("cluster", clusterName)
4650
.tag("topic", topic)
4751
.register(registry);
4852
}
4953

5054
private DistributionSummary polledBytes(String topic) {
51-
return DistributionSummary.builder("topic_polled_bytes")
55+
return DistributionSummary.builder(COMMON_PREFIX + "topic_polled_bytes")
5256
.description("Bytes polled from kafka topic")
5357
.tag("cluster", clusterName)
5458
.tag("topic", topic)
5559
.register(registry);
5660
}
5761

5862
private Timer pollTimer(String topic) {
59-
return Timer.builder("topic_poll_time")
63+
return Timer.builder(COMMON_PREFIX + "topic_poll_time")
6064
.description("Time spend in polling for topic")
6165
.tag("cluster", clusterName)
6266
.tag("topic", topic)
6367
.register(registry);
6468
}
6569

6670
private Counter pollThrottlingActivations() {
67-
return Counter.builder("poll_throttling_activations")
71+
return Counter.builder(COMMON_PREFIX + "poll_throttling_activations")
6872
.description("Number of poll throttling activations")
6973
.tag("cluster", clusterName)
7074
.register(registry);
7175
}
7276

7377
public AtomicInteger activeConsumers() {
7478
var count = new AtomicInteger();
75-
Gauge.builder("active_consumers", () -> count)
79+
Gauge.builder(COMMON_PREFIX + "active_consumers", () -> count)
7680
.description("Number of active consumers")
7781
.tag("cluster", clusterName)
7882
.register(registry);

0 commit comments

Comments
 (0)