RaidenE1 opened a new pull request, #20464:
URL: https://github.com/apache/kafka/pull/20464
- Background
Add new metrics for TasksLost, TasksAssigned and TasksRevoked in
`StreamsRebalanceListener`.
- Features Implemented
Added three rebalance latency metrics to DefaultStreamsRebalanceListener:
- `tasks-revoked-latency-avg/max` - Average/max latency when revoking tasks
- `tasks-assigned-latency-avg/max` - Average/max latency when assigning
tasks
- `tasks-lost-latency-avg/max` - Average/max latency when losing tasks
Main Changes
1. Created `RebalanceMetrics.java`
- Follows existing Streams ThreadMetrics pattern with static factory
methods
- Provides three methods to create sensors: `tasksRevokedSensor()`,
`tasksAssignedSensor()`, `tasksLostSensor()`
2. Modified DefaultStreamsRebalanceListener.java
- Added three Sensor member variables
- Updated constructor to accept `StreamsMetricsImpl` and threadId
parameters
- Records execution time in `onTasksRevoked()`, `onTasksAssigned()`, and
`onAllTasksLost()` methods
3. Modified StreamThread.java
- Pass `streamsMetrics` and `getName()` when creating
`DefaultStreamsRebalanceListener`
4. Added Comprehensive Tests
- `DefaultStreamsRebalanceListenerTest `- Added 6 tests to verify
metrics recording (both normal and exception cases)
- `RebalanceMetricsTest` - Verifies sensor creation logic
--
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]