Fix dotnet.thread_pool.queue.length to use ObservableUpDownCounter#126482
Merged
tarekgh merged 1 commit intodotnet:mainfrom Apr 2, 2026
Merged
Fix dotnet.thread_pool.queue.length to use ObservableUpDownCounter#126482tarekgh merged 1 commit intodotnet:mainfrom
tarekgh merged 1 commit intodotnet:mainfrom
Conversation
Change dotnet.thread_pool.queue.length from CreateObservableCounter to CreateObservableUpDownCounter. ThreadPool.PendingWorkItemCount reports a current snapshot that can decrease as work items are dequeued, so a monotonically increasing counter is incorrect. This is consistent with dotnet.thread_pool.thread.count which already uses CreateObservableUpDownCounter for the same reason. Add a test to verify the instrument type.
Member
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects the System.Runtime runtime metric dotnet.thread_pool.queue.length to use an instrument type that matches its semantics (a snapshot that can increase and decrease), aligning it with other non-monotonic runtime metrics like thread count.
Changes:
- Switch
dotnet.thread_pool.queue.lengthfromCreateObservableCountertoCreateObservableUpDownCounter. - Add a unit test that asserts the published instrument type is
ObservableUpDownCounter<long>.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs | Updates the runtime metric instrument type for thread pool queue length to be non-monotonic. |
| src/libraries/System.Diagnostics.DiagnosticSource/tests/RuntimeMetricsTests.cs | Adds a test validating the instrument type for dotnet.thread_pool.queue.length. |
Member
Author
|
Interesting, the docs https://github.com/open-telemetry/semantic-conventions/blob/02577f828b6ad061e76d27bdc994ca84959c71bf/docs/runtime/dotnet-metrics.md?plain=1#L432 and https://learn.microsoft.com/en-us/dotnet/core/diagnostics/built-in-metrics-runtime#metric-dotnetthread_poolqueuelength already showing |
cincuranet
approved these changes
Apr 2, 2026
noahfalk
approved these changes
Apr 2, 2026
rajkumar-rangaraj
approved these changes
Apr 2, 2026
This was referenced Apr 2, 2026
This was referenced Apr 3, 2026
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.
Fixes #126167
Change
dotnet.thread_pool.queue.lengthfromCreateObservableCountertoCreateObservableUpDownCounter.ThreadPool.PendingWorkItemCountreports a current snapshot that can decrease as work items are dequeued, so a monotonically increasing counter is incorrect. This is consistent withdotnet.thread_pool.thread.countwhich already usesCreateObservableUpDownCounterfor the same reason.Includes a test to verify the instrument type.