feat(metrics): track thread pool backlog#358
Conversation
yordis
commented
May 14, 2026
- Operators need visibility into work queued outside the node's named internal queues.
- Thread-pool pressure should appear in the same telemetry surface operators already use for queue health.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR SummaryMedium Risk Overview Updates Reviewed by Cursor Bugbot for commit d460a51. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d460a51. Configure here.
| { | ||
| var length = GetPendingWorkItemCount(); | ||
| _queueStats.ProcessingStarted<ThreadPoolBacklogSample>(length); | ||
| _queueStats.ReportQueueLength(length); |
There was a problem hiding this comment.
Redundant ReportQueueLength call after ProcessingStarted
Low Severity
ProcessingStarted<ThreadPoolBacklogSample>(length) already calls ReportQueueLength(length) internally (via the overload in QueueStatsCollector). The explicit _queueStats.ReportQueueLength(length) call immediately after is redundant since it applies Math.Max with the same value, producing no effect. This could mislead future maintainers into thinking the two calls serve distinct purposes.
Reviewed by Cursor Bugbot for commit d460a51. Configure here.
| if (Volatile.Read(ref _stopped) == 0) | ||
| { | ||
| _timer.Change(SampleInterval, Timeout.InfiniteTimeSpan); | ||
| } |
There was a problem hiding this comment.
Timer disposal race can throw during shutdown
Low Severity
A TOCTOU race exists between the Volatile.Read(ref _stopped) check and the _timer.Change(...) call in Execute(). If Dispose() is called concurrently (during shutdown), Stop() sets _stopped and then _timer.Dispose() runs between the check and the Change call, causing an ObjectDisposedException on the thread pool — which in .NET 6+ crashes the process by default.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d460a51. Configure here.

