opentelemetry-js
opentelemetry-js copied to clipboard
Add `host.id` detection to HostDetector
Is your feature request related to a problem? Please describe.
Similar to container.id the attribute host.id can be super helpful to provide correlation between infra & app data in the backend. Many (non-containerised) linux systems have a file called "machine-id" that holds a unique identifier, that is created on first boot and stays stable from there. I checked CentOS, Debian & Alpine and all of them provide that file in /etc/machine-id. Historically this file could also live at /var/lib/dbus/machine-id. I would like to have the HostDetector extended to check for these files and add host.id if available.
Describe the solution you'd like
I have the code ready at https://github.com/svrnm/opentelemetry-js/tree/add-host-id-detection, so if this is something worth being added I can raise the PR:
- https://github.com/svrnm/opentelemetry-js/blob/add-host-id-detection/packages/opentelemetry-resources/src/platform/node/HostDetector.ts
- https://github.com/svrnm/opentelemetry-js/blob/add-host-id-detection/packages/opentelemetry-resources/test/detectors/node/HostDetector.test.ts
Additional context
Spec Issue: https://github.com/open-telemetry/opentelemetry-specification/pull/2978