Skip to content

Feature Request: Expose Consumer Partition Lag Metrics (Similar to Java KafkaConsumer.partitionLag) #1391

Open
@visbvr

Description

@visbvr

Description:
Hi Confluent team! 👋

First, thank you for maintaining the confluent-kafka-go library—it’s been incredibly helpful. I’m writing to inquire about a feature present in the Java Kafka client that’s currently missing in the Go implementation: consumer partition lag tracking.

In the Java client, KafkaConsumer provides method
org.apache.kafka.clients.consumer.internals.SubscriptionState#partitionLag or org.apache.kafka.clients.consumer.internals.AsyncKafkaConsumer#currentLag

In confluent-kafka-go there’s no built-in way to directly retrieve partition lag. This requires developers to manually calculate lag, which can be error-prone. Especially if the topic contains transaction control records that cannot be consumed but increase the offset of the topic.

Questions:

  1. Is there a plan to add a convenience method (e.g., GetPartitionLag()) or expose consumer metrics like records-lag in the Go library?
  2. If this is not on the roadmap, could you recommend a best practice for calculating partition lag with the current API (e.g., combining QueryWatermarkOffsets and Position)?
  3. Are there any limitations or caveats to be aware of when calculating lag manually in Go?

Example Use Case:

// consume entire topic
while(partitionConsumer.currentLag > 0 ){
  // keep consuming
}
// end of topic reached

Java Reference:

Thank you for your time and insights! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions