Current state: Voting in progress
Discussion thread: https://lists.apache.org/thread/z4o5093zqxmc18nzb74vyhvb1hb399v4
Vote thread: https://lists.apache.org/thread/jxf789v0kdpvsb9wsosghh57odkksxt7
JIRA:
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
The Kafka consumer allows users to pause() and resume() individual partitions. When a partition is paused, subsequent calls to poll() will not return any records from that partition until it is resumed. This mechanism is used for application-level flow control and backpressure management.
Higher-level frameworks like Kafka Streams make extensive use of pause/resume internally:
StoreChangelogReader pauses and resumes changelog partitions on the restore consumer depending on whether the corresponding tasks still exist.Currently, there are no consumer metrics that expose pause/resume state. Operators and developers have no way to answer basic questions through monitoring:
This KIP proposes adding new consumer metrics that track paused partitions and their pause duration.
The metric will have the following tags:
| Metric Name | Type | Description |
| paused-partitions | Gauge (Integer) | The current number of partitions that have been paused by the user via Consumer.pause() . |
| paused-partitions-rate | Rate | The per-second rate of Consumer.pause() calls. |
| paused-partitions-total | CumulativeCount | The total cumulative number of Consumer.pause() calls. |
| paused-partitions-duration-max-seconds | Gauge (Long) | The maximum duration in seconds that any partition has been paused. Returns -1 if no partition is currently paused. |
Each metric will have the following tags:
| Metric Name | Type | Description |
| paused-partitions | Gauge (Integer) | Whether this partition is currently paused. Returns 1 if paused, 0 if not paused. |
| paused-partitions-duration-seconds | Gauge (Long) | The time in seconds since this partition was paused. Returns -1 if the partition is not currently paused. |
| paused-partitions-rate | Rate | The per-second rate of Consumer.pause() calls for this partition. |
| paused-partitions-total | CumulativeCount | The total cumulative number of Consumer.pause() calls for this partition. |
Note: These are per-partition metrics, consistent with existing per-partition consumer metrics such as records-lag and records-lead . Cardinality increases linearly with the number of assigned partitions, which may increase memory usage in the metrics registry and in downstream monitoring systems.
Currently, each partition's internal state tracks whether it is paused with a simple boolean flag. To support the paused-partitions-duration-seconds metric, this KIP adds a timestamp that records when the partition was paused. The timestamp is set when pause() is called, cleared (reset to -1) when resume() is called, and also reset to -1 on partition reassignment regardless of prior pause status. This ensures that a partition re-assigned to the same consumer after a rebalance starts with a clean pause state.
A paused-partitions gauge and paused-partitions-rate / paused-partitions-total sensors are registered at coordinator level. When queried, this gauge computes the current count of paused partitions by reading from the consumer's subscription state. Sensor metrics are updated on each pause() call, incrementing the cumulative count and contributing to the rate calculation.
The paused-partitions / paused-partitions-duration-seconds gauges and paused-partitions-rate / paused-partitions-total sensors are registered per partition in the fetch manager metrics, alongside the existing per-partition lag and lead metrics. They follow the same lifecycle:
This change only adds new metrics. No existing metrics or APIs are deprecated.
pause() is called, cleared on resume() , and reset on partition reassignment.N/A