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

Matthias J. Sax commented on KAFKA-19543:
-----------------------------------------

Maybe I misunderstand the ticket description? – I thought that it would be ok / 
expected, that:
{code:java}
consumer.metrics(); // return a Map of all metrics
consumer.close();
consumer.metrics(); // return an empty Map as all metrics got 
de-registered{code}
The other question you ask, if the metrics should be a snapshot vs dynamic seem 
to be an orthogonal question? And I think, yes, the metrics (ie, their values) 
should be dynamic, and reflect ongoing changes.

But re-reading the ticket it seem that the issue is as follows:
{code:java}
Map metrics = consumer.metrics();
consumer.close();
// the previously returned `metrics` Map lost some keys?{code}
This would indeed be odd. After consumer.close() I would only expect that the 
metric values don't change any longer, but not that whole entries disappear.

Should be an easy fix though, to make a "deep copy" of the metric Map? At least 
this is what we do in Kafka Streams.

> The set of metrics returned from Consumer.metrics() changes after 
> Consumer.close()
> ----------------------------------------------------------------------------------
>
>                 Key: KAFKA-19543
>                 URL: https://issues.apache.org/jira/browse/KAFKA-19543
>             Project: Kafka
>          Issue Type: Bug
>          Components: clients, consumer, metrics
>    Affects Versions: 4.1.0
>            Reporter: Kirk True
>            Assignee: Kirk True
>            Priority: Minor
>
> metrics() reflects the current state, so if you get the metrics before you 
> close and then look at them afterward, some of the metrics are missing 
> because some were removed.



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

Reply via email to