You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "chia7712 (via GitHub)" <gi...@apache.org> on 2025/01/01 12:15:39 UTC
Re: [PR] KAFKA-12469: Deprecated and corrected topic metrics for consumer (KIP-1109) [kafka]
chia7712 commented on code in PR #18232:
URL: https://github.com/apache/kafka/pull/18232#discussion_r1900385984
##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchMetricsManager.java:
##########
@@ -101,32 +105,38 @@ void recordRecordsFetched(int records) {
void recordBytesFetched(String topic, int bytes) {
String name = topicBytesFetchedMetricName(topic);
- Sensor bytesFetched = new SensorBuilder(metrics, name, () -> topicTags(topic))
- .withAvg(metricsRegistry.topicFetchSizeAvg)
- .withMax(metricsRegistry.topicFetchSizeMax)
- .withMeter(metricsRegistry.topicBytesConsumedRate, metricsRegistry.topicBytesConsumedTotal)
- .build();
+ maybeRecordDeprecatedBytesFetched(name, topic, bytes);
+
+ Sensor bytesFetched = new SensorBuilder(metrics, name, () -> Map.of("topic", topic))
+ .withAvg(metricsRegistry.topicFetchSizeAvg)
+ .withMax(metricsRegistry.topicFetchSizeMax)
+ .withMeter(metricsRegistry.topicBytesConsumedRate, metricsRegistry.topicBytesConsumedTotal)
+ .build();
bytesFetched.record(bytes);
}
void recordRecordsFetched(String topic, int records) {
String name = topicRecordsFetchedMetricName(topic);
- Sensor recordsFetched = new SensorBuilder(metrics, name, () -> topicTags(topic))
- .withAvg(metricsRegistry.topicRecordsPerRequestAvg)
- .withMeter(metricsRegistry.topicRecordsConsumedRate, metricsRegistry.topicRecordsConsumedTotal)
- .build();
+ maybeRecordDeprecatedRecordsFetched(name, topic, records);
+
+ Sensor recordsFetched = new SensorBuilder(metrics, name, () -> Map.of("topic", topic))
+ .withAvg(metricsRegistry.topicRecordsPerRequestAvg)
+ .withMeter(metricsRegistry.topicRecordsConsumedRate, metricsRegistry.topicRecordsConsumedTotal)
+ .build();
recordsFetched.record(records);
}
void recordPartitionLag(TopicPartition tp, long lag) {
this.recordsLag.record(lag);
String name = partitionRecordsLagMetricName(tp);
- Sensor recordsLag = new SensorBuilder(metrics, name, () -> topicPartitionTags(tp))
- .withValue(metricsRegistry.partitionRecordsLag)
- .withMax(metricsRegistry.partitionRecordsLagMax)
- .withAvg(metricsRegistry.partitionRecordsLagAvg)
- .build();
+ maybeRecordDeprecatedPartitionLag(name, tp, lag);
+
+ Sensor recordsLag = new SensorBuilder(metrics, name, () -> mkMap(mkEntry("topic", tp.topic()), mkEntry("partition", String.valueOf(tp.partition()))))
Review Comment:
@ijuma please see my previous comment https://github.com/apache/kafka/pull/18232#discussion_r1889943665
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org