Open morningspace opened 2 weeks ago
any updates?
The non-deprecated runtime uses runtime/metrics to retrieve metrics data. The metrics we exposed are documented in semantic conventions.
It looks like you're looking for go.memory.allocated and go.memory.used.
The current runtime does expose those two metrics on its latest version, even though it uses the runtime/metrics
package, not runtime.MemStats
.
Thanks @dmathieu for your reply!
runtime.memStats
, it has both memStats.HeapAlloc
and memStats.Alloc
available. So, I assume go.memory.allocated
maps to memStats.HeapAlloc
, not memStats.Alloc
.memStats.Sys
, that's the memory obtained from system. When I check the code in non-deprected runtime, I found it actually checks go heap memory defined here, which I'm not sure if it is identical to memStats.Sys
.cc @dashpole who led this.
Based on https://github.com/prometheus/client_golang/blob/76b74e25d5660965000a74cf2e918c217ed76da2/prometheus/go_collector.go#L26, this is the mapping from memStats to go runtime metrics:
memStats.Alloc
is the same as the /memory/classes/heap/objects:bytes
runtime metric.memStats.Sys
is the same as the /memory/classes/total:bytes
runtime metric./memory/classes/total:bytes
isn't useful on its own, as it includes released memory. For the new runtime metrics, we provide the go.memory.used
metric, which excludes released memory.
You can see https://github.com/golang/go/issues/67120 for why we don't provide live + unswept heap memory via /memory/classes/heap/objects:bytes
:
live+unswept heap memory isn't a terribly useful metric since it tends to be noisy and misleading, subject to sweep scheduling nuances. The heap goal is a much more reliable measure of total heap footprint.
In keeping with that, we would recommend using the go.memory.gc.goal
metric, which measures the heap goal.
Description
Some runtime metrics, e.g.:
memStats.Alloc
,memStats.Sys
, are missing.Steps To Reproduce
memStats.Alloc
,memStats.Sys
.Expected behavior
Can the missing runtime metrics be added? If a PR is allowed, we'd be happy to contribute.