Semantic Conventions for .NET Common Language Runtime (CLR) Metrics

Status: Experimental

This document describes semantic conventions for .NET CLR runtime metrics in OpenTelemetry.

.NET CLR Process

Status: Experimental

Description: .NET Common Language Runtime (CLR) metrics relating to the process, captured under the namespace dotnet.process.*.

Note: These metrics represent measurements observed from the perspective of the .NET process and may differ from metrics measured from outside the process (e.g. process.cpu.* and process.memory.usage).

Metric: dotnet.process.cpu.count

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.process.cpu.countUpDownCounter{cpu}The number of processors available to the process. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as accessing Environment.ProcessorCount.

Metric: dotnet.process.cpu.time

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.process.cpu.timeCountersCPU time used by the process. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as accessing the corresponding processor time properties on System.Diagnostics.Process.

AttributeTypeDescriptionExamplesRequirement LevelStability
cpu.modestringThe mode of the CPUuser; systemRequiredExperimental

cpu.mode has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
idleidleExperimental
interruptinterruptExperimental
iowaitiowaitExperimental
kernelkernelExperimental
niceniceExperimental
stealstealExperimental
systemsystemExperimental
useruserExperimental

Metric: dotnet.process.memory.working_set

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.process.memory.working_setUpDownCounterByThe number of bytes of physical memory mapped to the process context. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling Environment.WorkingSet.

.NET CLR Garbage Collection

Status: Experimental

Description: .NET Common Language Runtime (CLR) metrics relating to garbage collection, captured under the namespace dotnet.gc.*.

Metric: dotnet.gc.collections

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.gc.collectionsCounter{collection}The number of garbage collections that have occurred since the process has started. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric uses the GC.CollectionCount(int generation) API to calculate exclusive collections per generation.

AttributeTypeDescriptionExamplesRequirement LevelStability
dotnet.gc.heap.generationstringName of the garbage collector managed heap generation.gen0; gen1; gen2RequiredExperimental

dotnet.gc.heap.generation has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
gen0Generation 0Experimental
gen1Generation 1Experimental
gen2Generation 2Experimental
lohLarge Object HeapExperimental
pohPinned Object HeapExperimental

Metric: dotnet.gc.heap.total_allocated

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.gc.heap.total_allocatedCounterByThe approximate number of bytes allocated on the managed GC heap since the process has started. The returned value does not include any native allocations. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling GC.GetTotalAllocatedBytes().

Metric: dotnet.gc.last_collection.memory.committed_size

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.gc.last_collection.memory.committed_sizeUpDownCounterByThe amount of committed virtual memory in use by the .NET GC, as observed during the latest garbage collection. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling GC.GetGCMemoryInfo().TotalCommittedBytes. Committed virtual memory may be larger than the heap size because it includes both memory for storing existing objects (the heap size) and some extra memory that is ready to handle newly allocated objects in the future.

Metric: dotnet.gc.last_collection.heap.size

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.gc.last_collection.heap.sizeUpDownCounterByThe managed GC heap size (including fragmentation), as observed during the latest garbage collection. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling GC.GetGCMemoryInfo().GenerationInfo.SizeAfterBytes.

AttributeTypeDescriptionExamplesRequirement LevelStability
dotnet.gc.heap.generationstringName of the garbage collector managed heap generation.gen0; gen1; gen2RequiredExperimental

dotnet.gc.heap.generation has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
gen0Generation 0Experimental
gen1Generation 1Experimental
gen2Generation 2Experimental
lohLarge Object HeapExperimental
pohPinned Object HeapExperimental

Metric: dotnet.gc.last_collection.heap.fragmentation.size

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.gc.last_collection.heap.fragmentation.sizeUpDownCounterByThe heap fragmentation, as observed during the latest garbage collection. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling GC.GetGCMemoryInfo().GenerationInfo.FragmentationAfterBytes.

AttributeTypeDescriptionExamplesRequirement LevelStability
dotnet.gc.heap.generationstringName of the garbage collector managed heap generation.gen0; gen1; gen2RequiredExperimental

dotnet.gc.heap.generation has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
gen0Generation 0Experimental
gen1Generation 1Experimental
gen2Generation 2Experimental
lohLarge Object HeapExperimental
pohPinned Object HeapExperimental

Metric: dotnet.gc.pause.time

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.gc.pause.timeCountersThe total amount of time paused in GC since the process has started. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling GC.GetTotalPauseDuration().

.NET CLR Just-In-Time (JIT) Compiler

Status: Experimental

Description: .NET Common Language Runtime (CLR) metrics relating to the Just-In-Time compiler, captured under the namespace dotnet.jit.*.

Metric: dotnet.jit.compiled_il.size

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.jit.compiled_il.sizeCounterByCount of bytes of intermediate language that have been compiled since the process has started. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling JitInfo.GetCompiledILBytes().

Metric: dotnet.jit.compiled_methods

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.jit.compiled_methodsCounter{method}The number of times the JIT compiler (re)compiled methods since the process has started. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling JitInfo.GetCompiledMethodCount().

Metric: dotnet.jit.compilation.time

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.jit.compilation.timeCountersThe amount of time the JIT compiler has spent compiling methods since the process has started. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling JitInfo.GetCompilationTime().

.NET CLR Thread pool

Status: Experimental

Description: .NET Common Language Runtime (CLR) metrics relating to the thread pool, captured under the namespace dotnet.thread_pool.*.

Metric: dotnet.thread_pool.thread.count

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.thread_pool.thread.countUpDownCounter{thread}The number of thread pool threads that currently exist. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling ThreadPool.ThreadCount.

Metric: dotnet.thread_pool.work_item.count

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.thread_pool.work_item.countCounter{work_item}The number of work items that the thread pool has completed since the process has started. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling ThreadPool.CompletedWorkItemCount.

Metric: dotnet.thread_pool.queue.length

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.thread_pool.queue.lengthUpDownCounter{work_item}The number of work items that are currently queued to be processed by the thread pool. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling ThreadPool.PendingWorkItemCount.

.NET CLR General

Status: Experimental

Description: Other useful .NET Common Language Runtime (CLR) metrics.

Metric: dotnet.monitor.lock_contentions

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.monitor.lock_contentionsCounter{contention}The number of times there was contention when trying to acquire a monitor lock since the process has started. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling Monitor.LockContentionCount.

Metric: dotnet.timer.count

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.timer.countUpDownCounter{timer}The number of timer instances that are currently active. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling Timer.ActiveCount.

Metric: dotnet.assembly.count

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.assembly.countUpDownCounter{assembly}The number of .NET assemblies that are currently loaded. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as calling AppDomain.CurrentDomain.GetAssemblies().Length.

Metric: dotnet.exceptions

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStability
dotnet.exceptionsCounter{exception}The number of exceptions that have been thrown in managed code. [1]Experimental

[1]: Meter name: System.Runtime; Added in: .NET 9.0. This metric reports the same values as counting calls to AppDomain.CurrentDomain.FirstChanceException.

AttributeTypeDescriptionExamplesRequirement LevelStability
error.typestringDescribes a class of error the operation ended with.System.OperationCanceledException; Contoso.MyExceptionRequiredStable

error.type has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
_OTHERA fallback error value to be used when the instrumentation doesn’t define a custom value.Stable