opentelemetry-go icon indicating copy to clipboard operation
opentelemetry-go copied to clipboard

`host.id` resource auto-detection

Open mwear opened this issue 1 year ago • 0 comments

Problem Statement

I would like to be able collect host.id for non-containerized environments.

Proposed Solution

There is currently a spec PR: https://github.com/open-telemetry/opentelemetry-specification/pull/3173 that proposes using the following sources to collect host.id per platform:

OS Primary Fallback
Linux contents of /etc/machine-id contents of /var/lib/dbus/machine-id
BSD contents of /etc/hostid output of kenv -q smbios.system.uuid
MacOS IOPlatformUUID line from the output of ioreg -rd1 -c "IOPlatformExpertDevice" -
Windows MachineGuid from registry HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography -

Alternatives

We could use off the shelf libraries, although they differ in implementation from what is specified. It would also be a dependency we do not control.

Prior Art

Similar libraries:

  • gopsutil - https://github.com/shirou/gopsutil
  • machineid - https://github.com/denisbrodbeck/machineid/

This is the JS implementation of the spec proposal: https://github.com/open-telemetry/opentelemetry-js/pull/3575

Here is a PR that attempts to address the same problem in the collector (using gopsutil): https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/18740

Additional Context

I have an implementation that I will open as a PR shortly. Please assign this issue to me.

mwear avatar Feb 27 '23 22:02 mwear