Skip to content

Conversation

@emasab
Copy link
Contributor

@emasab emasab commented Nov 7, 2025

Statistics callback is available when using the promisified API with all client types.

Note for the reviewers: SetPollInBackground is moved to the Connection base class, false by default and it's public only on the Producer where it's possible to chose if polling externally. For the AdminClient it's enabled only if the statistics.interval.ms is set as the main reply queue wasn't polled.

Checklist

  • Contains customer facing changes? It's possible to set the statistics.interval.ms together with the stats_cb and receive the statistics
  • Did you add sufficient unit test and/or integration test coverage for this PR? Unit tests are present for the three client types

@emasab emasab requested a review from a team as a code owner November 7, 2025 15:00
Copilot AI review requested due to automatic review settings November 7, 2025 15:00
@emasab emasab requested a review from a team as a code owner November 7, 2025 15:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables statistics callback support in the promisified API for all client types (Producer, Consumer, and Admin). Previously, stats callbacks were only available in the non-promisified API. The implementation moves background polling setup from Producer to the base Connection class, allowing all client types to receive statistics events.

Key Changes:

  • Refactored SetPollInBackground from Producer-specific to Connection base class
  • Added stats callback configuration and event handling for Producer, Consumer, and Admin clients
  • Added comprehensive test coverage for stats callbacks across all three client types

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/connection.h Added SetPollInBackground method declaration and m_is_background_polling field to base Connection class
src/connection.cc Implemented SetPollInBackground method in Connection class with background polling queue management
src/producer.h Changed to use inherited SetPollInBackground from Connection class
src/producer.cc Removed Producer-specific SetPollInBackground implementation and m_is_background_polling field
src/admin.cc Added automatic background polling activation when statistics interval is configured
lib/kafkajs/_producer.js Added stats callback extraction, storage, and event listener registration
lib/kafkajs/_consumer.js Added stats callback extraction, storage, and event listener registration
lib/kafkajs/_admin.js Added stats callback extraction, storage, and event listener registration
test/promisified/producer/statsCallback.spec.js Added test verifying Producer receives stats callbacks
test/promisified/consumer/statsCallback.spec.js Added test verifying Consumer receives stats callbacks
test/promisified/admin/statsCallback.spec.js Added test verifying Admin receives stats callbacks
CHANGELOG.md Documented new statistics callback feature for promisified API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@airlock-confluentinc airlock-confluentinc bot force-pushed the dev_stats_callback_in_promisified_api branch 2 times, most recently from 22990aa to fc56b7e Compare November 7, 2025 15:11
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

Successfully merging this pull request may close these issues.

2 participants