Skip to content

Commit 8fe0252

Browse files
authored
Add kafka.request.time.avg (#1135)
1 parent b495ac8 commit 8fe0252

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

jmx-metrics/docs/target-systems/kafka.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ These metrics are sourced from Kafka's exposed Yammer metrics for each instance:
4242
* Attributes: `type`
4343
* Instrument Type: DoubleValueObserver
4444

45+
* Name: `kafka.request.time.avg`
46+
* Description: The average time the broker has taken to service requests
47+
* Unit: `ms`
48+
* Attributes: `type`
49+
* Instrument Type: DoubleValueObserver
50+
4551
* Name: `kafka.network.io`
4652
* Description: The bytes received or sent by the broker
4753
* Unit: `by`

jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/KafkaIntegrationTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ List<Consumer<Metric>> kafkaBrokerAssertions() {
126126
attrs -> attrs.containsOnly(entry("type", "produce")),
127127
attrs -> attrs.containsOnly(entry("type", "fetchfollower")),
128128
attrs -> attrs.containsOnly(entry("type", "fetchconsumer"))),
129+
metric ->
130+
assertGaugeWithAttributes(
131+
metric,
132+
"kafka.request.time.avg",
133+
"The average time the broker has taken to service requests",
134+
"ms",
135+
attrs -> attrs.containsOnly(entry("type", "produce")),
136+
attrs -> attrs.containsOnly(entry("type", "fetchfollower")),
137+
attrs -> attrs.containsOnly(entry("type", "fetchconsumer"))),
129138
metric ->
130139
assertGauge(
131140
metric,

jmx-metrics/src/main/resources/target-systems/kafka.groovy

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ otel.instrument(requestTime,
8686
"type" : { mbean -> mbean.name().getKeyProperty("request").toLowerCase() },
8787
],
8888
"99thPercentile", otel.&doubleValueCallback)
89-
90-
89+
otel.instrument(requestTime,
90+
"kafka.request.time.avg",
91+
"The average time the broker has taken to service requests",
92+
"ms",
93+
[
94+
"type" : { mbean -> mbean.name().getKeyProperty("request").toLowerCase() },
95+
],
96+
"Mean", otel.&doubleValueCallback)
9197

9298
def network = otel.mbeans(["kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec",
9399
"kafka.server:type=BrokerTopicMetrics,name=BytesOutPerSec"])

0 commit comments

Comments
 (0)