fede1024 / rust-rdkafka

A fully asynchronous, futures-based Kafka client library for Rust based on librdkafka
MIT License
1.54k stars 259 forks source link

No stats being printed to logs #682

Open coding-yogi opened 1 month ago

coding-yogi commented 1 month ago

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)?;
  4. Once consumer is created, I just loop
    loop {
    //sleep 1 sec
    }
  5. I expect logs to be printed with via stats method every 10 secs

Checklist

Guyzeroth commented 1 month ago

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