Skip to content

Expose Task Queue Stats in DescribeVersion#2172

Open
carlydf wants to merge 7 commits intomasterfrom
versioning-ga/describe-version-with-tq-stats
Open

Expose Task Queue Stats in DescribeVersion#2172
carlydf wants to merge 7 commits intomasterfrom
versioning-ga/describe-version-with-tq-stats

Conversation

@carlydf
Copy link
Contributor

@carlydf carlydf commented Jan 31, 2026

What was changed

Expose Task Queue Stats in DescribeVersion

Why?

Mainly so that I can use this in the CLI, since the CLI describe-version already depends on Go SDK.
Worker controller, which also uses Go SDK, might also use this.

Checklist

  1. Closes

  2. How was this tested:

New functional test

  1. Any docs updates needed?

Note

Medium Risk
Expands an experimental client API and wires through optional task-queue stats from server responses; risk is mainly compatibility/behavioral around nil vs populated stats and server support for the new fields.

Overview
WorkerDeploymentHandle.DescribeVersion now supports an opt-in ReportTaskQueueStats flag and returns TaskQueueInfos containing each polled task queue along with optional Stats and StatsByPriorityKey backlog metrics.

This adds proto-to-SDK conversion helpers for per-priority stats, deprecates WorkerDeploymentVersionInfo.TaskQueuesInfos in favor of the new response field, and includes a new functional test that verifies stats are returned only when requested (with and without workflow priority keys).

Written by Cursor Bugbot for commit d6f3f68. This will update automatically on new commits. Configure here.

@carlydf carlydf requested a review from a team as a code owner January 31, 2026 01:12
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

}
result := make(map[int32]TaskQueueStats, len(statsByPriorityKey))
for priority, stats := range statsByPriorityKey {
result[priority] = *statsFromResponse(stats)
Copy link

Choose a reason for hiding this comment

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

Nil pointer dereference when map contains nil stats value

High Severity

The statsByPriorityKeyFromResponse function dereferences the return value of statsFromResponse(stats) directly. Since statsFromResponse returns nil when its input is nil, if any entry in the statsByPriorityKey map has a nil value for stats, the expression *statsFromResponse(stats) will cause a nil pointer dereference panic.

Fix in Cursor Fix in Web

tqInfo.Stats.ApproximateBacklogAge.Nanoseconds() > 0 &&
tqInfo.Stats.TasksAddRate > 0 &&
tqInfo.Stats.TasksDispatchRate == 0 && // zero task dispatch due to no pollers
tqInfo.Stats.BacklogIncreaseRate > 0) {
Copy link

Choose a reason for hiding this comment

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

Test checks aggregate stats instead of per-priority stats

Medium Severity

When checking the default priority key (3), the test verifies tqInfo.Stats (aggregate task queue stats) instead of priorityKeyStats (per-priority stats). The comment states the intent is to check the priority key's ApproximateBacklogCount, but the code checks the aggregate stats. This mismatch means the test doesn't actually validate that per-priority stats are correctly reported for the default priority key.

Fix in Cursor Fix in Web

// WorkerDeploymentTaskQueueInfo describes properties of the Task Queues involved
// in a Deployment Version.
//
// NOTE: Experimental
Copy link
Contributor

Choose a reason for hiding this comment

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

I am thinking this worker deployment client maybe should step back and have proper cross-SDK design. We are suffering some parity issues leaving this long-experimental thing inside of a single SDK. I think we may be able to approve the PR though. Is this just for CLI? Or is this for general user use and completeness sake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for the CLI.
I could rewrite the CLI to not depend on the Go SDK (and I think we maybe should implement CLI from gRPC in the future), but that involves a lot of code deletion, so I wanted to propose this change instead.

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