-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
The process/runtime/heap_alloc_bytes
/process_runtime_heap_alloc_bytes
metric is defined as
Bytes of allocated heap objects (see 'go doc runtime.MemStats.HeapAlloc')
but, since #45, the actual value is runtime.MemStats.HeapAlloc
minus the memory ballast size if the memory_ballast
extension is being used:
opentelemetry-collector/service/internal/proctelemetry/process_telemetry.go
Lines 283 to 293 in 7030388
func (pm *processMetrics) readMemStatsIfNeeded() { | |
now := time.Now() | |
// If last time we read was less than one second ago just reuse the values | |
if now.Sub(pm.lastMsRead) < time.Second { | |
return | |
} | |
pm.lastMsRead = now | |
runtime.ReadMemStats(pm.ms) | |
if pm.ballastSizeBytes > 0 { | |
pm.ms.Alloc -= pm.ballastSizeBytes | |
pm.ms.HeapAlloc -= pm.ballastSizeBytes |
This delays the process metrics initialization until extensions are running:
opentelemetry-collector/service/service.go
Line 223 in 7030388
if err = proctelemetry.RegisterProcessMetrics(srv.telemetryInitializer.ocRegistry, srv.telemetryInitializer.mp, obsreportconfig.UseOtelForInternalMetricsfeatureGate.IsEnabled(), getBallastSize(srv.host)); err != nil { |
We should remove this special case and change the metric to report the raw value of runtime.MemStats.HeapAlloc
instead, which will simplify both the metric's semantics as well as the implementation of telemetry initialization. If we keep using the memory ballast extension (see the separate issue #8343 for discussion on this, which may happen after this change), we can add a metric to the memory_ballast
extension to indicate the memory ballast size and be able to recover the previous value reported by this metric.
If we find out it is not desirable to just report runtime.MemStats.HeapAlloc
, we should instead change the metric description to state that the memory ballast value is removed.