Semantic conventions for Go runtime metrics

Status: Development

This document describes semantic conventions for Go runtime metrics in OpenTelemetry. These metrics are obtained from Go’s runtime/metrics package.

Go memory

Description: Go runtime metrics captured under the namespace go.memory.*

Metric: go.memory.used

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.memory.usedUpDownCounterByMemory used by the Go runtime. [1]Development

[1]: Computed from (/memory/classes/total:bytes - /memory/classes/heap/released:bytes).

Attributes:

KeyStabilityRequirement LevelValue TypeDescriptionExample Values
go.memory.typeDevelopmentRecommendedstringThe type of memory.other; stack
go.memory.detailed_typeDevelopmentOpt-InstringThe detailed type of memory. [1]heap/objects; heap/free

[1] go.memory.detailed_type: Value SHOULD match the specific memory class reported by the Go runtime under /memory/classes/.... The list of possible values is subject to change with the Go version used.


go.memory.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
otherMemory used by the Go runtime, excluding other categories of memory usage described in this enumeration.Development
stackMemory allocated from the heap that is reserved for stack space, whether or not it is currently in-use. [2]Development

[2]: Computed from /memory/classes/heap/stacks:bytes.

As of Go 1.26, the go.memory.detailed_type attribute has the following relationship to the go.memory.type attribute. Values for go.memory.detailed_type are subject to change with the Go version used:

go.memory.typego.memory.detailed_type
otherheap/free
otherheap/objects
otherheap/unused
othermetadata/mcache/free
othermetadata/mcache/inuse
othermetadata/mspan/free
othermetadata/mspan/inuse
othermetadata/other
otheros-stacks
otherother
otherprofiling/buckets
stackheap/stacks

Metric: go.memory.limit

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.memory.limitUpDownCounterByGo runtime memory limit configured by the user, if a limit exists. [1]Development

[1]: Computed from /gc/gomemlimit:bytes. This metric is excluded if the limit obtained from the Go runtime is math.MaxInt64.

Metric: go.memory.allocated

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.memory.allocatedCounterByMemory allocated to the heap by the application. [1]Development

[1]: Computed from /gc/heap/allocs:bytes.

Metric: go.memory.allocations

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.memory.allocationsCounter{allocation}Count of allocations to the heap by the application. [1]Development

[1]: Computed from /gc/heap/allocs:objects.

Go garbage collection

Description: Go metrics captured under the namespace go.memory.gc.*

Metric: go.memory.gc.goal

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.memory.gc.goalUpDownCounterByHeap size target for the end of the GC cycle. [1]Development

[1]: Computed from /gc/heap/goal:bytes.

Metric: go.memory.gc.cycles

This metric is opt-in.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.memory.gc.cyclesCounter{gc_cycle}Number of completed GC cycles. [1]Development

[1]: Computed from /gc/cycles/total:gc-cycles.

Metric: go.memory.gc.pause.duration

This metric is opt-in.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.memory.gc.pause.durationHistogramsDistribution of individual GC-related stop-the-world pause latencies. This is the time from deciding to stop the world until the world is started again. [1]Development

[1]: Computed from /sched/pauses/total/gc:seconds. Bucket boundaries are provided by the runtime, and are subject to change.

Go CPU

Description: Go runtime metrics captured under the namespace go.cpu.*

Metric: go.cpu.time

This metric is opt-in.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.cpu.timeCountersEstimated CPU time spent by the Go runtime. [1]Development

[1]: Computed from /cpu/classes/... metrics. This metric is an overestimate, and not directly comparable to system CPU time measurements. Compare only with other go.cpu.time metrics.

Attributes:

KeyStabilityRequirement LevelValue TypeDescriptionExample Values
go.cpu.stateDevelopmentRequiredstringThe state of the CPU.user; gc
go.cpu.detailed_stateDevelopmentOpt-InstringThe detailed state of the CPU. [1]gc/pause; gc/mark/assist

[1] go.cpu.detailed_state: Value SHOULD match the specific CPU class reported by the Go runtime under /cpu/classes/.... The list of possible values is subject to change with the Go version used.


go.cpu.state 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
gcCPU time spent performing garbage collection tasks.Development
idleAvailable CPU time not spent executing any Go or Go runtime code.Development
scavengeCPU time spent returning unused memory to the underlying platform.Development
userCPU time spent running user Go code.Development

As of Go 1.26, the go.cpu.detailed_state attribute has the following relationship to the go.cpu.state attribute. Values for go.cpu.detailed_state are subject to change with the Go version used:

go.cpu.statego.cpu.detailed_state
useruser
gcgc/mark/assist
gcgc/mark/dedicated
gcgc/mark/idle
gcgc/pause
scavengescavenge/assist
scavengescavenge/background
idleidle

Go goroutines

Description: Go metrics captured under the namespace go.goroutine.*

Metric: go.goroutine.count

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.goroutine.countUpDownCounter{goroutine}Count of live goroutines. [1]Development

[1]: Computed from /sched/goroutines:goroutines.

Go processor

Description: Go metrics captured under the namespace go.processor.*

Metric: go.processor.limit

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.processor.limitUpDownCounter{thread}The number of OS threads that can execute user-level Go code simultaneously. [1]Development

[1]: Computed from /sched/gomaxprocs:threads.

Go scheduler

Description: Go metrics captured under the namespace go.schedule.*

Metric: go.schedule.duration

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.schedule.durationHistogramsThe time goroutines have spent in the scheduler in a runnable state before actually running. [1]Development

[1]: Computed from /sched/latencies:seconds. Bucket boundaries are provided by the runtime, and are subject to change.

Go runtime configuration

Description: Go metrics captured under the namespace go.config.*

Metric: go.config.gogc

This metric is recommended.

NameInstrument TypeUnit (UCUM)DescriptionStabilityEntity Associations
go.config.gogcUpDownCounter%Heap size target percentage configured by the user, otherwise 100. [1]Development

[1]: The value range is [0.0,100.0]. Computed from /gc/gogc:percent.