ywango opened a new issue, #21491: URL: https://github.com/apache/pulsar/issues/21491
### Search before asking - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar. ### Version 2.11.0 and above ### Minimal reproduce step 1. Create a non-partitioned topic 2. Create a producer with the default 60sec statsInterval that can publish messages to topic in step 1 3. Publish 1 message every 10 sec, and 20 messages in total 4. Fetch the producer stats every 20sec by querying `getStats()` method and print out values of [getNumMsgsSent()](https://github.com/apache/pulsar/blob/v3.1.0/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ProducerStats.java#L39C10-L39C24) and [getTotalMsgsSent()](https://github.com/apache/pulsar/blob/v3.1.0/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ProducerStats.java#L99) in [ProducerStats.java](https://github.com/apache/pulsar/blob/v3.1.0/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ProducerStats.java) 5. Check the printed logs ### What did you expect to see? Both `getNumMsgsSent()` and `getTotalMsgsSent()` should be constant values during each statsInterval(60sec) per the [description](https://github.com/apache/pulsar/blob/v3.1.0/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ProducerStats.java#L30), as all stats are referring to the last recording period(last stats interval) ### What did you see instead? - `getNumMsgsSent()` is actually the number of messages published in the current interval, **NOT** the last interval - `getNumMsgsSent()` is being updated within the interval Implementation also indicates current interval [ProducerStatsRecorderImpl.java](https://github.com/apache/pulsar/blob/v3.1.0/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerStatsRecorderImpl.java#L141-L144) ### Anything else? Client stats that are referring to current in progress interval - [ProducerStats](https://github.com/apache/pulsar/blob/v3.1.0/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ProducerStats.java#L36-L54) - [ConsumerStats (part-1)](https://github.com/apache/pulsar/blob/v3.1.0/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ConsumerStats.java#L40-L45) - [ConsumerStats (part-2)](https://github.com/apache/pulsar/blob/v3.1.0/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/ConsumerStats.java#L60-L75) Is there any ongoing plan to fix the documentation or the implementation ? ### Are you willing to submit a PR? - [X] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
