Emit estimated tasks per datastream as a metric and log - #1048
Merged
harshOSS merged 1 commit intoAug 17, 2026
Merged
Conversation
Add a per-datastream `estimatedNumTasks` gauge in StickyPartitionAssignmentStrategy that reports the estimated number of tasks calculated for a datastream, along with an INFO log of the same value. The existing numTasksCappedByMaxTasks meter is only emitted when the estimate exceeds maxTasks, so there was no visibility into the estimated task count for streams that are not being capped. Both the gauge and the log are emitted from validateNumTasksAgainstMaxTasks, right before the estimate is compared against maxTasks. That is the choke point shared by StickyPartitionAssignmentStrategy and LoadBasedPartitionAssignmentStrategy, so both strategies are covered, and the reported value is the estimate before it gets capped. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
harshOSS
force-pushed
the
hmadhav/emit-estimated-tasks-per-datastream-metric
branch
from
August 17, 2026 03:26
246e9a6 to
f2b92a9
Compare
dhananjay-sawner
left a comment
Collaborator
There was a problem hiding this comment.
Just curious why do we need this metric?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a per-datastream
estimatedNumTasksgauge, plus an INFO log of the same value, reporting the estimated number of tasks calculated for a datastream.numTasksCappedByMaxTasksmeter and a WARN log, but only when the estimate exceeds the datastream'smaxTasks. There is no visibility into the estimated task count for streams that are not being capped.maxTasksand against the actualnumTasks.The emission lives in
StickyPartitionAssignmentStrategy.validateNumTasksAgainstMaxTasks(), the choke point shared byStickyPartitionAssignmentStrategy(partition-count based estimate) andLoadBasedPartitionAssignmentStrategy(throughput/load based estimate), so both strategies are covered. The reported value is the estimate before it is capped atmaxTasks.StickyPartitionAssignmentStrategy.<datastreamTaskPrefix>.estimatedNumTasksEstimated number of tasks calculated for datastream <taskPrefix>: <estimate>The gauge is declared in
getMetricInfos(), registered alongside the existing per-datastream gauges (numTasks,actualPartitionsPerTask,elasticTaskParametersNeedAdjustment), and unregistered with them.Known limitations (pre-existing behavior, intentionally not changed here)
LoadBasedPartitionAssignmentStrategy.unregisterMetricsdoes not chain to the base class, so per-datastream gauges of deleted streams can retain their last value there. This affects the existing gauges in the same way and is out of scope for this change.Testing Done
TestStickyPartitionAssignmentStrategy.testElasticTaskPartitionAssignmentCreatesAtMostMaxTasksasserts the new gauge reports the uncapped estimate (13) whilenumTasksreports the capped actual (5)TestLoadBasedPartitionAssignmentStrategy.testValidThroughputBasedPartitionAssignmentPathasserts the gauge is emitted on the load-based path as wellTestStickyPartitionAssignmentStrategy(19 tests) andTestLoadBasedPartitionAssignmentStrategy(7 tests) pass under JDK 17TestCoordinator.testCoordinationWithPartitionAssignmentandTestCoordinator.testCoordinationWithElasticTaskAssignmentPartitionAssignmentpasscheckstyleMainandcheckstyleTestpass🤖 Generated with GitHub Copilot CLI