add host.id to resource auto-detection#3812
add host.id to resource auto-detection#3812MadVikingGod merged 12 commits intoopen-telemetry:mainfrom
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3812 +/- ##
======================================
Coverage ? 81.5%
======================================
Files ? 170
Lines ? 12765
Branches ? 0
======================================
Hits ? 10415
Misses ? 2131
Partials ? 219
|
4eb70b5 to
a154c62
Compare
|
|
||
| // WithHostID adds host ID information to the configured resource. | ||
| func WithHostID() Option { | ||
| return WithDetectors(hostIDDetector{}) |
There was a problem hiding this comment.
Shouldn't we add hostIDDetector to WithHost()? We might consider adding WithHostName to offer a resource detector that only sets host.name resource attribute.
There was a problem hiding this comment.
Because the rules for detecting HostID are different for containerized vs non-containerized hosts I didn't want to couple the hostIDDetector to WithHost, although I had considered it. My thoughts were that someone who wanted to use WithHost on a cloud provider wouldn't have to worry about detector order when detecting HostID. However, I could see having WithHost that detects HostID and HostName, and separate options WithHostID and WithHostName to collect the attributes individually. Let me know what your preference is.
There was a problem hiding this comment.
EDIT: After second thought, I have no strong preference. Maybe we should improve the docs and list all the attributes that given detector (option) should set? This could be addressed in a separate issue as I feel this is a problem not only for this detector/option.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This allows us to run tests for the BSD, Darwin, and Linux readers on all platforms.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
|
I wanted to check in to see if there is anything that anyone would like to see addressed in this PR? |
This PR adds host id detection support for non-containerized hosts. The implementation is based on this spec pr: open-telemetry/opentelemetry-specification#3173.
Fixes #3811
Summary
hostIDReaderinterface with platform specific implementations for Darwin, Linux, BSD, Windows and a fallback for unsupported platfoms.host.id, aka machine id for non-containerized environments. Depending on platform this involves reading files in well known locations, excuting shell commands, or a combination of the two.See also
I realize we will want to see the spec PR merge before getting too serious about this work, but I wanted to get some eyes on the approach and encourage anyone with opinions to provide feedback here and on the spec PR.