:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(ingestion-consumer): support KIP-848 consumer group protocol (#63508)
José Sequeiraedb3f085dcd6
diff --git a/rust/ingestion-consumer/src/config.rs b/rust/ingestion-consumer/src/config.rsindex b6fd0187c6d8..9411ebea7e3d 100644--- a/rust/ingestion-consumer/src/config.rs+++ b/rust/ingestion-consumer/src/config.rs@@ -274,6 +274,10 @@ impl Config {builder = builder.set(key, value);}+ // After all overrides: if KAFKA_CONSUMER_GROUP_PROTOCOL=consumer selected the+ // KIP-848 protocol, drop the classic-only keys librdkafka would reject.+ builder = builder.strip_classic_protocol_keys_if_consumer();+builder.build()}}diff --git a/rust/ingestion-consumer/src/kafka_config.rs b/rust/ingestion-consumer/src/kafka_config.rsindex d786d57f2aa1..419493865268 100644--- a/rust/ingestion-consumer/src/kafka_config.rs+++ b/rust/ingestion-consumer/src/kafka_config.rs@@ -197,8 +197,70 @@ impl ConsumerConfigBuilder {self}+ /// Strip classic-only keys when the KIP-848 consumer group protocol is selected.+ ///+ /// When `group.protocol=consumer`, librdkafka rejects the whole config at+ /// startup if any classic-only key is set: `session.timeout.ms`,+ /// `heartbeat.interval.ms` (broker-side under KIP-848) and+ /// `partition.assignment.strategy` (replaced by the server-side+ /// `group.remote.assignor`). Remove them after the full config is built so+ /// the batch-consumer defaults don't break a consumer opted into the new+ /// protocol. Mirrors the Node.js `stripClassicProtocolConfig`.+ ///+ /// `group.instance.id` (static membership) is intentionally kept — KIP-848+ /// supports it.+ pub fn strip_classic_protocol_keys_if_consumer(mut self) -> Self {+ let is_consumer_protocol = self.config.get("group.protocol") == Some("consumer");+ if is_consumer_protocol {+ for key in [+ "session.timeout.ms",+ "heartbeat.interval.ms",+ "partition.assignment.strategy",+ "group.protocol.type",+ ] {+ self.config.remove(key);+ }+ }+ self+ }+/// Build the final configurationpub fn build(self) -> ClientConfig {self.config}}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn strips_classic_keys_under_consumer_protocol() {+ let config = ConsumerConfigBuilder::for_batch_consumer("kafka:9092", "g")+ .with_sticky_partition_assignment(Some("pod-1"))+ .set("group.protocol", "consumer")+ .strip_classic_protocol_keys_if_consumer()+ .build();++ assert_eq!(config.get("group.protocol"), Some("consumer"));+ assert_eq!(config.get("session.timeout.ms"), None);+ assert_eq!(config.get("heartbeat.interval.ms"), None);+ assert_eq!(config.get("partition.assignment.strategy"), None);+ // Static membership is valid under KIP-848 and must survive the strip.+ assert_eq!(config.get("group.instance.id"), Some("pod-1"));+ }++ #[test]+ fn keeps_classic_keys_under_classic_protocol() {+ let config = ConsumerConfigBuilder::for_batch_consumer("kafka:9092", "g")+ .with_sticky_partition_assignment(None)+ .strip_classic_protocol_keys_if_consumer()+ .build();++ assert_eq!(config.get("session.timeout.ms"), Some("60000"));+ assert_eq!(+ config.get("partition.assignment.strategy"),+ Some("cooperative-sticky")+ );+ }+}