[ 
https://issues.apache.org/jira/browse/KAFKA-19753?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18024333#comment-18024333
 ] 

Charles-Eddy edited comment on KAFKA-19753 at 10/3/25 8:44 AM:
---------------------------------------------------------------

Hey you are right, it is not clear, but in our case if we put the same name and 
tags, under the hood they are considered duplicates when registered and one of 
them will be discarded. (like we want)

 

EDIT: after doing tests, what's above does not work, the metrics are merged 
instead of being deduplicated and therefore each increment of one of them is 
incrementing the same counter


was (Author: JIRAUSER301644):
Hey you are right, it is not clear, but in our case if we put the same name and 
tags, under the hood they are considered duplicates when registered and one of 
them will be discarded. (like we want)

> Metrics from FetchMetricsManager containing a topic tag are duplicated
> ----------------------------------------------------------------------
>
>                 Key: KAFKA-19753
>                 URL: https://issues.apache.org/jira/browse/KAFKA-19753
>             Project: Kafka
>          Issue Type: Bug
>          Components: consumer, metrics
>    Affects Versions: 4.1.0
>            Reporter: Charles-Eddy
>            Priority: Minor
>         Attachments: Screenshot 2025-10-03 at 09.44.11.png, Screenshot 
> 2025-10-03 at 09.46.42.png
>
>
> Hello,
> Since Kafka 4.1.0, we're experiencing an issue with Kafka Streams metrics for 
> topics containing dots in their names. (I think the problem is also for 
> simple usage of consumers not only kstream)
> In FetchMetricsManager, methods like {{recordRecordsFetched()}} now create 
> duplicate sensors for the same topic if they contain dot in their name: 
> {code:java}
> void recordRecordsFetched(String topic, int records) { 
>  String name = topicRecordsFetchedMetricName(topic); 
>  maybeRecordDeprecatedRecordsFetched(name, topic, records); <-- here we 
> create another sensor if the topic name contains dot
>  Sensor recordsFetched = new SensorBuilder(metrics, name, () -> 
> Map.of("topic", topic)) 
>  .withAvg(metricsRegistry.topicRecordsPerRequestAvg) 
>  .withMeter(metricsRegistry.topicRecordsConsumedRate, 
> metricsRegistry.topicRecordsConsumedTotal) 
>  .build(); 
>  recordsFetched.record(records); 
>  }  {code}
> It currently record two sensors, one with my original topic name, one time 
> with a topic name with dots replaced by underscore. 
> -While we can work around this by reversing the transformation in our case 
> (replacing underscores back to dots in Micrometer filters) or by removing 
> this specific list of metrics, this does not feel like a long-term solution 
> for us.-
> Currently using spring-boot and micrometer, it's really hard to remove one of 
> those duplicated metrics. 
> Could a configuration option be added to disable one of the two sensor to 
> avoid having duplicated metrics?
> Thanks in advance



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to