.NET 中已知的 EventCounters

.NET 執行階段和程式庫會實作及發佈數個 EventCounters,可用於識別和診斷各種效能問題。 關於用來監視這些計數器及其描述的提供者,本文可作為參考資料。 如果您使用 .NET 較新的 System.Diagnostics.Metrics API,請改為參閱已知的計量參考

System.Runtime 計數器

下列計數器會發佈為 .NET 執行階段 (CoreCLR) 的一部分,且在 RuntimeEventSource.cs 中進行維護。

計數器 描述 首度可用版本
% Time in GC since last GC (time-in-gc) 自上次 GC 起 GC 的時間百分比 .NET Core 3.1
Allocation Rate (alloc-rate) 各更新間隔配置的位元組數目 .NET Core 3.1
CPU Usage (cpu-usage) 處理序的 CPU 使用量百分比 (相對於所有系統 CPU 資源) .NET Core 3.1
Exception Count (exception-count) 已發生的例外狀況數目 .NET Core 3.1
GC Heap Size (gc-heap-size) 要根據 GC.GetTotalMemory(Boolean) 配置的 MB 數目 .NET Core 3.1
Gen 0 GC Count (gen-0-gc-count) 各更新間隔 Gen 0 的 GC 發生次數 .NET Core 3.1
Gen 0 Size (gen-0-size) Gen 0 GC 的位元組數目 .NET Core 3.1
Gen 1 GC Count (gen-1-gc-count) 各更新間隔 Gen 1 的 GC 發生次數 .NET Core 3.1
Gen 1 Size (gen-1-size) Gen 1 GC 的位元組數目 .NET Core 3.1
Gen 2 GC Count (gen-2-gc-count) 各更新間隔 Gen 2 的 GC 發生次數 .NET Core 3.1
Gen 2 Size (gen-2-size) Gen 2 GC 的位元組數目 .NET Core 3.1
LOH Size (loh-size) 大型物件堆積的位元組數目 .NET Core 3.1
POH Size (poh-size) 釘選的物件堆積位元組數目 (.NET 5 以上版本可用) .NET Core 3.1
GC Fragmentation (gc-fragmentation) GC 堆積片段 (.NET 5 以上版本可用) .NET Core 3.1
Monitor Lock Contention Count (monitor-lock-contention-count) 根據 Monitor.LockContentionCount 嘗試取得監視器鎖定時的爭用次數 .NET Core 3.1
Number of Active Timers (active-timer-count) 根據 Timer.ActiveCount 的目前作用中 Timer 執行個體數目 .NET Core 3.1
Number of Assemblies Loaded (assembly-count) 在特定時間點載入處理序的 Assembly 執行個體數目 .NET Core 3.1
ThreadPool Completed Work Item Count (threadpool-completed-items-count) ThreadPool 中目前已處理的工作項目數目 .NET Core 3.1
ThreadPool Queue Length (threadpool-queue-length) 目前在 ThreadPool 中排入佇列待處理的工作項目數目 .NET Core 3.1
ThreadPool Thread Count (threadpool-thread-count) 根據 ThreadPool.ThreadCount 目前 ThreadPool 中執行緒集區的執行緒數目 .NET Core 3.1
Working Set (working-set) 根據 Environment.WorkingSet 時間點,對應至處理序內容的實體記憶體 MB 數 .NET Core 3.1
IL Bytes Jitted (il-bytes-jitted) JIT 編譯的 IL 大小總計,以位元組為單位 .NET 5
Methods Jitted Count (methods-jitted-count) JIT 編譯的方法數目 .NET 5
GC Committed Bytes (gc-committed) GC 所認可的位元組數目 .NET 6

Microsoft.AspNetCore.Hosting 計數器

下列計數器會發佈為 ASP.NET Core 的一部分,且在 HostingEventSource.cs 中進行維護。

計數器 描述 首度可用版本
Current Requests (current-requests) 已啟動但尚未停止的要求總數 .NET Core 3.1
Failed Requests (failed-requests) 應用程式存留期發生的失敗要求總數 .NET Core 3.1
Request Rate (requests-per-second) 各更新間隔發生的要求數目 .NET Core 3.1
Total Requests (total-requests) 應用程式存留期發生的要求總數 .NET Core 3.1

Microsoft.AspNetCore.Http.Connections 計數器

下列計數器會發佈為 ASP.NET Core SignalR 的一部分,且在 HttpConnectionsEventSource.cs 中進行維護。

計數器 描述 首度可用版本
Average Connection Duration (connections-duration) 連線的平均持續時間,以毫秒為單位 .NET Core 3.1
Current Connections (current-connections) 已啟動但尚未停止的作用中連線數目 .NET Core 3.1
Total Connections Started (connections-started) 已啟動的連線總數 .NET Core 3.1
Total Connections Stopped (connections-stopped) 已停止的連線總數 .NET Core 3.1
Total Connections Timed Out (connections-timed-out) 已逾時的連線總數 .NET Core 3.1

Microsoft-AspNetCore-Server-Kestrel 計數器

下列計數器會發佈為 ASP.NET Core Kestrel 網路伺服器的一部分,且在 KestrelEventSource.cs 中進行維護。

計數器 描述 首度可用版本
Connection Queue Length (connection-queue-length) 佇列的目前長度 .NET 5
Connection Rate (connections-per-second) 各更新間隔連線至網頁伺服器的數目 .NET 5
Current Connections (current-connections) Web 伺服器的目前作用中連線數目 .NET 5
Current TLS Handshakes (current-tls-handshakes) 目前的 TLS 交握數目 .NET 5
Current Upgraded Requests (WebSockets) (current-upgraded-requests) 目前的升級要求數目 (WebSockets) .NET 5
Failed TLS Handshakes (failed-tls-handshakes) 失敗的 TLS 交握總數 .NET 5
Request Queue Length (request-queue-length) 佇列目前長度 .NET 5
TLS Handshake Rate (tls-handshakes-per-second) 各更新間隔的 TLS 交握數目 .NET 5
Total Connections (total-connections) Web 伺服器的連線總數 .NET 5
Total TLS Handshakes (total-tls-handshakes) 與網頁伺服器 TLS 交握的總次數 .NET 5

System.Net.Http 計數器

HTTP 堆疊會發佈下列計數器。

計數器 描述 首度可用版本
Requests Started (requests-started) 處理序開始後啟動的要求數目 .NET 5
Requests Started Rate (requests-started-rate) 各更新間隔啟動的要求數目 .NET 5
Requests Failed (requests-failed) 處理序開始後失敗的要求數目 .NET 5
Requests Failed Rate (requests-failed-rate) 各更新間隔失敗的要求數目 .NET 5
Current Requests (current-requests) 目前已啟動、但尚未完成或失敗的作用中 HTTP 要求數目 .NET 5
Current HTTP 1.1 Connections (http11-connections-current-total) 目前已啟動、但尚未完成或失敗的 HTTP 1.1 連線數目 .NET 5
Current HTTP 2.0 Connections (http20-connections-current-total) 目前已啟動、但尚未完成或失敗的 HTTP 2.0 連線數目 .NET 5
Current HTTP 3.0 Connections (http30-connections-current-total) 目前已啟動、但尚未完成或失敗的 HTTP 3.0 連線數目 .NET 7
HTTP 1.1 Requests Queue Duration (http11-requests-queue-duration) HTTP 1.1 要求在要求佇列中花費的平均持續時間 .NET 5
HTTP 2.0 Requests Queue Duration (http20-requests-queue-duration) HTTP 2.0 要求在要求佇列中花費的平均持續時間 .NET 5
HTTP 3.0 Requests Queue Duration (http30-requests-queue-duration) HTTP 3.0 要求在要求佇列中花費的平均持續時間 .NET 7

System.Net.NameResolution 計數器

下列計數器會追蹤與 DNS 查閱相關的計量。

計數器 描述 首度可用版本
DNS Lookups Requested (dns-lookups-requested) 處理序開始後要求的 DNS 查閱數目 .NET 5
Average DNS Lookup Duration (dns-lookups-duration) DNS 查閱所花費的平均時間 .NET 5
Current DNS Lookups (current-dns-lookups) 目前已啟動、但尚未完成或失敗的 DNS 查閱數目 .NET 6

System.Net.Security 計數器

下列計數器會追蹤與傳輸層安全性通訊協定相關的計量。

計數器 描述 首度可用版本
TLS handshakes completed (tls-handshake-rate) 各更新間隔完成的 TLS 交握數目 .NET 5
Total TLS handshakes completed (total-tls-handshakes) 處理序開始後完成的 TLS 交握總數 .NET 5
Current TLS handshakes (current-tls-handshakes) 目前已啟動、但尚未完成的 TLS 交握數目 .NET 5
Total TLS handshakes failed (failed-tls-handshakes) 處理序開始後失敗的 TLS 交握總數 .NET 5
All TLS Sessions Active (all-tls-sessions-open) 任何版本的作用中 TLS 工作階段數目 .NET 5
TLS 1.0 Sessions Active (tls10-sessions-open) 作用中的 TLS 1.0 工作階段數目 .NET 5
TLS 1.1 Sessions Active (tls11-sessions-open) 作用中的 TLS 1.1 工作階段數目 .NET 5
TLS 1.2 Sessions Active (tls12-sessions-open) 作用中的 TLS 1.2 工作階段數目 .NET 5
TLS 1.3 Sessions Active (tls13-sessions-open) 作用中的 TLS 1.3 工作階段數目 .NET 5
TLS Handshake Duration (all-tls-handshake-duration) 所有 TLS 交握的平均持續時間 .NET 5
TLS 1.0 Handshake Duration (tls10-handshake-duration) TLS 1.0 交握的平均持續時間 .NET 5
TLS 1.1 Handshake Duration (tls11-handshake-duration) TLS 1.1 交握的平均持續時間 .NET 5
TLS 1.2 Handshake Duration (tls12-handshake-duration) TLS 1.2 交握的平均持續時間 .NET 5
TLS 1.3 Handshake Duration (tls13-handshake-duration) TLS 1.3 交握的平均持續時間 .NET 5

System.Net.Sockets 計數器

下列計數器會追蹤與 Socket 相關的計量。

計數器 描述 首度可用版本
Outgoing Connections Established (outgoing-connections-established) 處理序開始後建立的傳出連線總數 .NET 5
Incoming Connections Established (incoming-connections-established) 處理序開始後建立的傳入連線總數 .NET 5
Current Outgoing Connect Attempts (current-outgoing-connect-attempts) 目前已啟動、但尚未完成或失敗的傳出連線嘗試次數 .NET 7
Bytes Received (bytes-received) 處理序開始後收到的位元組總數 .NET 5
Bytes Sent (bytes-sent) 處理序開始後傳送的位元組總數 .NET 5
Datagrams Received (datagrams-received) 處理序開始後收到的資料包總數 .NET 5
Datagrams Sent (datagrams-sent) 處理序開始後傳送的資料包總數 .NET 5