KIP-843 — Adding addMetricIfAbsent method to Metrics
Accepted Kafka 3.3 Metrics
Adds `Metrics.addMetricIfAbsent(MetricName, Measurable)` as an atomic get-or-create operation on the metrics registry. The existing two-step pattern (check existence, then `addMetric`) is not thread-safe: concurrent threads registering the same instance-level metric race and one throws `IllegalArgumentException`.
Details
| Author | Sagar Rao |
| Status | Accepted |
| Kafka Version | 3.3 |
| JIRA | KAFKA-13846 |
| Wiki | View on Apache Wiki |
| Created | 2022-05-23 |
| Last Modified | 2022-06-16 |
Explore how this KIP affects the Kafka protocol in the Protocol Explorer, or see the full KIP database.