This fixes an issue where Stats.GetSelf() would fail when run inside a container while using a hostfs path, as the PID returned by os.Getpid() would not be valid outside the container runtime.
This changes the logic, so if we have a hostfs set, GetSelf will fetch the pid from /hostf/proc/self.
Why is it important?
This is a bug.
Checklist
[x] My code follows the style guidelines of this project
[x] I have commented my code, particularly in hard-to-understand areas
[x] I have added tests that prove my fix is effective or that my feature works
Closes https://github.com/elastic/elastic-agent-system-metrics/issues/147
What does this PR do?
This fixes an issue where
Stats.GetSelf()
would fail when run inside a container while using a hostfs path, as the PID returned byos.Getpid()
would not be valid outside the container runtime.This changes the logic, so if we have a
hostfs
set,GetSelf
will fetch the pid from/hostf/proc/self
.Why is it important?
This is a bug.
Checklist
CHANGELOG.md