Skip to content

[RESOURCE DETECTOR] Add the host resource detector - #4418

Merged
marcalff merged 6 commits into
open-telemetry:mainfrom
mateenali66:feat/4413-host-detector
Aug 13, 2026
Merged

[RESOURCE DETECTOR] Add the host resource detector#4418
marcalff merged 6 commits into
open-telemetry:mainfrom
mateenali66:feat/4413-host-detector

Conversation

@mateenali66

Copy link
Copy Markdown
Contributor

Fixes #4413

Changes

Adds the host resource detector in resource_detectors/, setting host.name, host.arch and host.id per semantic conventions, with Linux, MacOS and Windows support.

Platform specifics, also documented on the class:

  • host.name: gethostname() on Linux/MacOS, GetComputerNameExW() on Windows
  • host.id: /etc/machine-id with /var/lib/dbus/machine-id fallback on Linux, gethostuuid() on MacOS, the HKLM\SOFTWARE\Microsoft\Cryptography\MachineGuid registry value on Windows. Omitted when no source is available (for example Linux containers without a machine id).
  • host.arch: mapped at compile time from predefined architecture macros to the semconv values, omitted for architectures the conventions do not enumerate.

Follows the process detector layout (detector + detail/ utils split for testability). Verified by running the utils on MacOS arm64 (hostname, arm64, hardware UUID all populated); Linux and Windows paths exercised in CI.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
@mateenali66
mateenali66 requested a review from a team as a code owner August 12, 2026 00:17
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.43478% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.58%. Comparing base (2499c49) to head (f4d3c12).

Files with missing lines Patch % Lines
resource_detectors/src/host_detector.cc 71.43% 6 Missing ⚠️
resource_detectors/src/host_detector_utils.cc 88.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4418      +/-   ##
==========================================
- Coverage   82.59%   82.58%   -0.01%     
==========================================
  Files         509      511       +2     
  Lines       19972    20018      +46     
==========================================
+ Hits        16494    16529      +35     
- Misses       3478     3489      +11     
Files with missing lines Coverage Δ
resource_detectors/src/host_detector_utils.cc 88.00% <88.00%> (ø)
resource_detectors/src/host_detector.cc 71.43% <71.43%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>

@dbarker dbarker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you! Just requesting addition of this detector to the install test.

Comment thread resource_detectors/test/host_detector_test.cc
Signed-off-by: Mateen Anjum <mateenali66@gmail.com>

@marcalff marcalff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the feature.

Comment thread resource_detectors/src/host_detector.cc Outdated
…ource

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
@marcalff
marcalff merged commit 089779d into open-telemetry:main Aug 13, 2026
176 of 187 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RESOURCE DETECTOR] Host resource detector

4 participants