Skip to content

[receiver/hostmetrics] Use MemAvailable for Used memory calculation (Linux) #42221

@rogercoll

Description

@rogercoll

Component(s)

receiver/hostmetrics/internal/scraper/memoryscraper

Is your feature request related to a problem? Please describe.

Current memory "used" calculation is based on the old formula used by the free (and procps utils) command on Linux: Used = Total - Free - Buffers - Cached(with SReclaimable)

The issue is that this formula is not accurate because the Cached includes memory that is not freeable. That's why the Linux Kernel 3.14 introduced the MemAvailable state: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773

Gopsutil (the library used by the receiver to fetch the data) will be switching to the new formula: https://github.com/shirou/gopsutil/pull/1882 (issue

Describe the solution you'd like

Introduce a feature gate that provides a smooth migration for users to the new formula calculation.

Describe alternatives you've considered

No response

Additional context

Semantic Conventions: open-telemetry/semantic-conventions#2534
Ongoing discussion about default memory states: open-telemetry/semantic-conventions#2538

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions