Get Consumer lag using LibrdkafkaHandle.OutQueueLength
See original GitHub issueDescription
Hi!
I found a way to get a consumer’s topic lag by reading the internal property OutQueueLength found in the internal LibrdkafkaHandle Handle property of the consumer. Is this a “safe” hack? @mhowlett, can you please explain me why this property was not publicly exposed in the library? If this version is not safe is there another way to accomplish this? Thank you, Alex
Code:
var propertyLevel1 = _consumer.Handle.GetType().GetProperty("LibrdkafkaHandle", BindingFlags.NonPublic | BindingFlags.Instance);
var valueLevel1 = propertyLevel1.GetValue(_consumer.Handle);
var propertyLevel2 = valueLevel1.GetType().GetProperty("OutQueueLength", BindingFlags.NonPublic | BindingFlags.Instance);
var valueLevel2 = propertyLevel2.GetValue(valueLevel1);
topicLag = Convert.ToInt64(valueLevel2);
Checklist
Please provide the following information:
- A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.
- Confluent.Kafka nuget version: 1.3.0
- Apache Kafka version: 2.x
- Client configuration.
- Operating system : Linux
- Provide logs (with “debug” : “…” as necessary in configuration).
- Provide broker log excerpts.
- Critical issue.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Consumergroup lag statistics · Issue #1822
The consumer lag is only calculated when partitions have been assigned and are fetched. When you use the high-level balanced consumer (-G) it ......
Read more >Untitled
Check lag kafka Check all the lags in Kafka - Stack Overflow Get comprehensive ... You can use kafka-consumer-groups.sh command to find out...
Read more >Monitoring the Kafka consumer lag
An efficient streaming application requires consumer lag to be minimal, a higher consumer lag indicates performance problems with the consumers.
Read more >Monitor Consumer Lag in Confluent Cloud
Monitor Consumer Latency via Client Interceptors You can use Confluent Control Center to track consumer latency and more.
Read more >Monitor the Consumer Lag in Apache Kafka
Kafka consumer group lag is a key performance indicator of any Kafka-based event-driven system. In this tutorial, we'll build an analyzer ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @edenhill ! Can you please tell me how I can do this in the C# library? Should I hack the same way I did above?
@wxlevel You have to
Subscribe
to your topic for consumer to be assigned to partitions.