Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
visbvr opened this issue Feb 19, 2025 · 0 comments

Comments

@visbvr
Copy link

visbvr commented Feb 19, 2025

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! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant