[RuntimeMetrics] Add additional metrics for JIT, ThreadPool, and GC diagnostics #8052
+262
−3
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 of changes
This PR extends the runtime metrics collection to include 13 new high-value metrics that were previously missing:
JIT Metrics (.NET 6+):
runtime.dotnet.jit.compiled_il_bytes- Total IL bytes compiled by JITruntime.dotnet.jit.compiled_methods- Total methods compiled by JITruntime.dotnet.jit.compilation_time- Total JIT compilation time (milliseconds)ThreadPool Metrics:
runtime.dotnet.threads.queue_length- ThreadPool work item queue length (.NET Core 3.0+)runtime.dotnet.threads.available_worker_threads- Available ThreadPool worker threadsruntime.dotnet.threads.available_completion_port_threads- Available ThreadPool I/O completion port threadsruntime.dotnet.threads.completed_work_items- Completed ThreadPool work items (.NET 5+)runtime.dotnet.threads.active_timers- Active timer count (.NET 6+)GC Metrics:
runtime.dotnet.gc.allocated_bytes- Total allocated bytes (.NET Core 3.0+)runtime.dotnet.gc.fragmentation_percent- Heap fragmentation percentageruntime.dotnet.gc.total_available_memory- Container-aware total available memoryruntime.dotnet.gc.high_memory_load_threshold- GC high memory pressure trigger thresholdruntime.dotnet.gc.size.poh- Pinned Object Heap size (.NET 5+)Reason for change
The existing runtime metrics implementation was missing several important metrics that are essential for:
Implementation details
Architecture
Extended both existing runtime metrics listeners to maintain compatibility across all supported platforms:
DiagnosticsMetricsRuntimeMetricsListener (.NET 6+)
System.Runtime.JitInfoAPIs for JIT metricsRuntimeEventListener (.NET Core 3.1+, also runs on .NET 6+)
Platform Support Matrix
Other details
Performance Impact