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

Add `host.id` detection to HostDetector

Open svrnm opened this issue 3 years ago • 0 comments

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

svrnm avatar Nov 23 '22 09:11 svrnm