Skip to content

Conversation

@chernser
Copy link
Contributor

@chernser chernser commented Nov 8, 2025

Summary

  • Adds Sink tasks metrics
  • Adds topic metrics

Sink task and topic metrics are accessible via JMX. Bean name format is com.clickhouse:type=ClickHouseKafkaConnector,name=SinkTask<taskId>,version=<version>.
For example, com.clickhouse:type=ClickHouseKafkaConnector,name=SinkTask0,version=v1.3.5.

Topic metrics bean name format is com.clickhouse:type=ClickHouseKafkaConnector,name=SinkTask<taskId>,version=<version>,topic=<topic>.
For example com.clickhouse:type=ClickHouseKafkaConnector,name=SinkTask0,version=v1.3.5,topic=schemaless_simple_batch_test_1762822854777.

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

@chernser chernser requested review from Copilot and mzitnik November 10, 2025 14:36
Copy link
Contributor

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 implements metrics collection and JMX monitoring capabilities for the ClickHouse Kafka connector sink tasks. The changes enable tracking of key performance indicators such as record processing rates, batch statistics, event lag times, and insert durations.

Key changes:

  • Introduces JMX MBeans for exposing sink task and topic-level statistics
  • Adds tracking of successful/failed records and batches, receive lag, and insert time metrics
  • Updates test infrastructure to register/unregister MBeans properly in test lifecycle

Reviewed Changes

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

Show a summary per file
File Description
TopicStatisticsMBean.java Defines MBean interface for topic-level metrics (success/failure counts, lag, insert time)
TopicStatistics.java Implements topic statistics tracking using atomic counters and exponential moving averages
SinkTaskStatisticsMBean.java Adds getInsertedRecords method to sink task MBean interface
SinkTaskStatistics.java Enhances statistics collection with thread-safe atomics, topic-level tracking, and MBean registration
Processing.java Integrates statistics recording for insert operations including event receive lag calculation
ClickHouseWriter.java Records insert time metrics across all insert method variants
ProxySinkTask.java Refactors to use final fields and handles MBean lifecycle management
ClickHouseSinkTask.java Exposes taskId accessor for test verification
ProcessingTest.java Updates tests to properly manage SinkTaskStatistics MBean lifecycle
ClickHouseWriterTest.java Updates constructor calls to pass SinkTaskStatistics instances
ClickHouseSinkTaskTest.java Adds comprehensive tests for metrics validation and mean lag time calculation

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

@chernser chernser marked this pull request as ready for review November 11, 2025 00:53
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