From 9835f411d7a230c790e0ad3ff2c4a1997adb649a Mon Sep 17 00:00:00 2001 From: mackjmr Date: Fri, 15 Dec 2023 11:10:02 +0100 Subject: [PATCH] Add kafka.request.time.avg This PR adds metric `kafka.request.time.avg` for `kafka.network:type=RequestMetrics,name=TotalTimeMs,request={Produce,FetchConsumer,FetchFollower}`. It does so by collecting from the `Mean` attribute.` --- jmx-metrics/docs/target-systems/kafka.md | 6 ++++++ .../target_systems/KafkaIntegrationTest.java | 9 +++++++++ .../src/main/resources/target-systems/kafka.groovy | 10 ++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/jmx-metrics/docs/target-systems/kafka.md b/jmx-metrics/docs/target-systems/kafka.md index 7a0307626..a90dbdd0f 100644 --- a/jmx-metrics/docs/target-systems/kafka.md +++ b/jmx-metrics/docs/target-systems/kafka.md @@ -42,6 +42,12 @@ These metrics are sourced from Kafka's exposed Yammer metrics for each instance: * Attributes: `type` * Instrument Type: DoubleValueObserver +* Name: `kafka.request.time.avg` +* Description: The average time the broker has taken to service requests +* Unit: `ms` +* Attributes: `type` +* Instrument Type: DoubleValueObserver + * Name: `kafka.network.io` * Description: The bytes received or sent by the broker * Unit: `by` diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/KafkaIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/KafkaIntegrationTest.java index 20b3b0c37..acc272262 100644 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/KafkaIntegrationTest.java +++ b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/KafkaIntegrationTest.java @@ -126,6 +126,15 @@ List> kafkaBrokerAssertions() { attrs -> attrs.containsOnly(entry("type", "produce")), attrs -> attrs.containsOnly(entry("type", "fetchfollower")), attrs -> attrs.containsOnly(entry("type", "fetchconsumer"))), + metric -> + assertGaugeWithAttributes( + metric, + "kafka.request.time.avg", + "The average time the broker has taken to service requests", + "ms", + attrs -> attrs.containsOnly(entry("type", "produce")), + attrs -> attrs.containsOnly(entry("type", "fetchfollower")), + attrs -> attrs.containsOnly(entry("type", "fetchconsumer"))), metric -> assertGauge( metric, diff --git a/jmx-metrics/src/main/resources/target-systems/kafka.groovy b/jmx-metrics/src/main/resources/target-systems/kafka.groovy index 3e4088aac..456f28573 100644 --- a/jmx-metrics/src/main/resources/target-systems/kafka.groovy +++ b/jmx-metrics/src/main/resources/target-systems/kafka.groovy @@ -86,8 +86,14 @@ otel.instrument(requestTime, "type" : { mbean -> mbean.name().getKeyProperty("request").toLowerCase() }, ], "99thPercentile", otel.&doubleValueCallback) - - +otel.instrument(requestTime, + "kafka.request.time.avg", + "The average time the broker has taken to service requests", + "ms", + [ + "type" : { mbean -> mbean.name().getKeyProperty("request").toLowerCase() }, + ], + "Mean", otel.&doubleValueCallback) def network = otel.mbeans(["kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec", "kafka.server:type=BrokerTopicMetrics,name=BytesOutPerSec"])