You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplify initialization of RuntimeMetrics (#105539)
* Simplify initialization of RuntimeMetrics
- Trigger the RuntimeMetrics initialization only when actually needed in the MeterListener constructor.
- Delete the lock-ordering workaround and wrong comment introduced in #105259. Trigger the RuntimeMetrics initialization only when actually needed should make the lock-ordering workarond unnecessary.
* Delete unnecessary static fields
* Update src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs
// Dummy method to ensure that the static constructor run and created the meters
28
+
}
29
+
23
30
staticRuntimeMetrics()
24
31
{
32
+
s_meter.CreateObservableCounter(
33
+
"dotnet.gc.collections",
34
+
GetGarbageCollectionCounts,
35
+
unit:"{collection}",
36
+
description:"The number of garbage collections that have occurred since the process has started.");
37
+
38
+
s_meter.CreateObservableUpDownCounter(
39
+
"dotnet.process.memory.working_set",
40
+
()=>Environment.WorkingSet,
41
+
unit:"By",
42
+
description:"The number of bytes of physical memory mapped to the process context.");
43
+
44
+
s_meter.CreateObservableCounter(
45
+
"dotnet.gc.heap.total_allocated",
46
+
()=>GC.GetTotalAllocatedBytes(),
47
+
unit:"By",
48
+
description:"The approximate number of bytes allocated on the managed GC heap since the process has started. The returned value does not include any native allocations.");
description:"The number of times the JIT compiler (re)compiled methods since the process has started.");
98
+
99
+
s_meter.CreateObservableCounter(
100
+
"dotnet.monitor.lock_contentions",
101
+
()=>Monitor.LockContentionCount,
102
+
unit:"{contention}",
103
+
description:"The number of times there was contention when trying to acquire a monitor lock since the process has started.");
104
+
105
+
s_meter.CreateObservableCounter(
106
+
"dotnet.thread_pool.thread.count",
107
+
()=>(long)ThreadPool.ThreadCount,
108
+
unit:"{thread}",
109
+
description:"The number of thread pool threads that currently exist.");
110
+
111
+
s_meter.CreateObservableCounter(
112
+
"dotnet.thread_pool.work_item.count",
113
+
()=>ThreadPool.CompletedWorkItemCount,
114
+
unit:"{work_item}",
115
+
description:"The number of work items that the thread pool has completed since the process has started.");
116
+
117
+
s_meter.CreateObservableCounter(
118
+
"dotnet.thread_pool.queue.length",
119
+
()=>ThreadPool.PendingWorkItemCount,
120
+
unit:"{work_item}",
121
+
description:"The number of work items that are currently queued to be processed by the thread pool.");
122
+
123
+
s_meter.CreateObservableUpDownCounter(
124
+
"dotnet.timer.count",
125
+
()=>Timer.ActiveCount,
126
+
unit:"{timer}",
127
+
description:"The number of timer instances that are currently active. An active timer is registered to tick at some point in the future and has not yet been canceled.");
description:"The approximate number of bytes allocated on the managed GC heap since the process has started. The returned value does not include any native allocations.");
description:"The number of timer instances that are currently active. An active timer is registered to tick at some point in the future and has not yet been canceled.");
0 commit comments