Skip to content

Add host.id resource detector#4843

Open
jaydeluca wants to merge 10 commits into
open-telemetry:mainfrom
jaydeluca:resource-detector-host
Open

Add host.id resource detector#4843
jaydeluca wants to merge 10 commits into
open-telemetry:mainfrom
jaydeluca:resource-detector-host

Conversation

@jaydeluca

@jaydeluca jaydeluca commented Jul 20, 2026

Copy link
Copy Markdown
Member

Description

This PR adds a host.id resource detector following the semconv spec, and using the java agent implementation as a reference.

Fixes #4830

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I wrote a small test app, and added

...
from opentelemetry.resource.detector.host import HostIdResourceDetector
...

    resource = get_aggregated_resources(
        detectors=[HostIdResourceDetector()],
        initial_resource=Resource.create(
            {ResourceAttributes.SERVICE_NAME: "host-detector-manual-test"}
        ),
    )

Ran the app (on macOS) and observed the attribute

image

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@jaydeluca
jaydeluca requested a review from a team as a code owner July 20, 2026 18:55
return SimpleNamespace(stdout=stdout, stderr="", returncode=return_code)


class HostIdResourceDetectorTest(TestBase):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we update these tests so that they test as much of the functionality end-to-end as possible? Almost everything is being patched here, which doesn't make these tests that useful. Our CI runs on both Linux and Windows so you should be able to at least test these systems end-to-end.

@github-project-automation github-project-automation Bot moved this to Reviewed PRs that need fixes in Python PR digest Jul 22, 2026
Comment thread .github/workflows/generate_workflows.py Outdated
workflows_directory_path,
"ubuntu-latest",
additional_jobs={
"py312-test-resource-detector-host-latest": ("windows-latest",),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not sure if there's a better way for me to run this on windows but scope it to just this test suite?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You shouldn't need to touch these files at all, you should be able to just have pytest skip the platform specific tests if they don't match

@herin049 herin049 Jul 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Look at @pytest.mark.skipif or @unittest.skipIf

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

if you'd prefer, i can remove all of this to keep it simple for now and followup with a change scoped to just introducing the change to run this on a windows runner. the windows specific tests just won't run for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

Add host.id resource attribute detector

3 participants