rust-rdkafka icon indicating copy to clipboard operation
rust-rdkafka copied to clipboard

No stats being printed to logs

Open coding-yogi opened this issue 1 year ago • 1 comments

Description

I am using a custom context with below code

 struct CustomContext; 
 impl ConsumerContext for CustomContext {} 
 impl ClientContext for CustomContext { 
    fn stats(&self, statistics: rdkafka::Statistics) {
        log::info!("{:?}", statistics);                
    } 
} 

This context is then passed to create a BaseConsumer client . The statistics.interval.ms is being set to 10000 in ClientConfig

How to reproduce

  1. Create context as defined above
  2. set following in config client_config.set("statistics.interval.ms", "10000");
  3. Create base consumer with context
 let context = CustomContext;
 let base_consumer = BaseConsumer::from_config_and_context(config, context)?;
  1. Once consumer is created, I just loop
loop {
  //sleep 1 sec
}
  1. I expect logs to be printed with via stats method every 10 secs

Checklist

  • [x] rdkafka version : v0.36.2
  • [x] Apache Kafka version: Bitnami Kafka Docker image
               "OS_ARCH=amd64",
               "OS_FLAVOUR=debian-12",
               "OS_NAME=linux",
               "APP_VERSION=3.7.0",
               "BITNAMI_APP_NAME=kafka",
  • [x] client configuration: statistics.interval.ms=10000
  • [x] Host Operating system: Ubuntu

coding-yogi avatar May 07 '24 12:05 coding-yogi

Hello, did you subscribe the consumer to a topic first? Try that and then call poll().

Guyzeroth avatar Jun 01 '24 05:06 Guyzeroth