kevin-wu24 commented on code in PR #18304: URL: https://github.com/apache/kafka/pull/18304#discussion_r1934780863
########## raft/src/main/java/org/apache/kafka/raft/internals/KafkaRaftMetrics.java: ########## @@ -137,6 +99,14 @@ public KafkaRaftMetrics(Metrics metrics, String metricGrpPrefix, QuorumState sta "Number of unknown voters whose connection information is not cached; would never be larger than quorum-size."); metrics.addMetric(this.numUnknownVoterConnectionsMetricName, (mConfig, currentTimeMs) -> numUnknownVoterConnections); + this.numVotersMetricName = metrics.metricName("number-of-voters", metricGroupName, "Number of voters for a KRaft topic partition."); + metrics.addMetric(this.numVotersMetricName, (Gauge<Integer>) (mConfig, currentTimestamp) -> numVoters); Review Comment: Maybe I'm misunderstanding. Whenever I don't perform an explicit cast to a `Gauge<T>`, the method being called is ``` addMetric(MetricName metricName, Measurable measurable) ``` and not ``` public void addMetric(MetricName metricName, MetricValueProvider<?> metricValueProvider) ``` When the passed in lambda is an implementation of `Measurable`, calling `measure()` to read the metric value returns a `double`, meaning `int numVoters` gets up-casted to a `double` when it doesn't need to be. This applies to other metrics as well, not just the one added in this PR. -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org