Skip to content

Conversation

@rogercoll
Copy link
Contributor

@rogercoll rogercoll commented Aug 25, 2025

Description

The useMemAvailable feature gate will use the MemAvailable kernel's statistic to compute the "used" memory usage. The PR performs the calculation of Used memory by using the raw memory values, this will prevent having a different "Used" value once gopsutil upgrades.

Link to tracking issue

Fixes #42221

Testing

Added a unit test to verify the formulas result to different values.

Documentation

The useMemAvailable feature gate will use the MemAvailable kernel's
statistic to compute the "used" memory usage.
@rogercoll rogercoll marked this pull request as ready for review August 25, 2025 16:18
@rogercoll rogercoll requested review from a team, braydonk and dmitryax as code owners August 25, 2025 16:18
Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @braydonk @dmitryax please take a look

@rogercoll
Copy link
Contributor Author

rogercoll commented Sep 8, 2025

The upstream gopsutil changes has been merged, released and adopted in the receiver: #42409

The new formula will be automatically used if this PR is not merged.

cc @braydonk @dmitryax

…mory_scraper_linux.go

Co-authored-by: Braydon Kains <93549768+braydonk@users.noreply.github.com>

var useMemAvailable = featuregate.GlobalRegistry().MustRegister(
"receiver.hostmetricsreceiver.UseLinuxMemAvailable",
featuregate.StageAlpha,
Copy link
Member

@dmitryax dmitryax Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we already moved to the updated Used from gopsutil. So we don't need this PR anymore. Or we can make it beta to not get back

Copy link
Contributor Author

@rogercoll rogercoll Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, moved to beta so users can still roll out to the previous formula

@rogercoll rogercoll force-pushed the mem_used_feature_gate branch from ecec14d to ff010f5 Compare September 23, 2025 08:25
@dmitryax dmitryax merged commit e67bf10 into open-telemetry:main Sep 23, 2025
185 of 186 checks passed
@github-actions github-actions bot added this to the next release milestone Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

6 participants