Skip to content

[RESOURCE] Process resource detector reports more attributes - #4437

Merged
marcalff merged 43 commits into
open-telemetry:mainfrom
LevelVoid:add-required-attributes
Aug 29, 2026
Merged

[RESOURCE] Process resource detector reports more attributes#4437
marcalff merged 43 commits into
open-telemetry:mainfrom
LevelVoid:add-required-attributes

Conversation

@LevelVoid

@LevelVoid LevelVoid commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #4436

Changes

  • Add process.creation.time, process.owner, (deferred: process.executable.build_id.htlhash) and process.executable.name with declaration in resource_detectors/include/opentelemetry/resource_detectors/detail/process_detector_utils.h and implementation in resource_detectors/src/process_detector_utils.cc .
  • Add updated function calls in resource_detectors/src/process_detector.cc.
  • Add unit tests and integration tests in resource_detectors/test/process_detector_test.cc.
  • Update Readme and docstrings.

Please provide a brief description of the changes here.

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

@LevelVoid
LevelVoid requested a review from a team as a code owner August 15, 2026 11:39
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 15, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@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.

Thanks for the PR! Please see feedback below.

Comment thread resource_detectors/src/process_detector_utils.cc Outdated
Comment thread resource_detectors/src/process_detector_utils.cc Outdated
Comment thread resource_detectors/src/process_detector_utils.cc Outdated
Comment thread resource_detectors/src/process_detector_utils.cc Outdated
Comment thread resource_detectors/src/process_detector_utils.cc Outdated
@LevelVoid

Copy link
Copy Markdown
Contributor Author

@dbarker Thanks for the review and feedback! I've made the changes

  • Combined GetExecutableName and GetExecutablePath into GetExecutableInfo.
  • Moved include statements to top of the file
  • Added conditional logic to handle files less than 4096 bytes
  • Added ComputeSha256Hex with correctness tests

@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.

Thanks for the updates!

Comment thread resource_detectors/src/process_detector_utils.cc Outdated
Comment thread resource_detectors/src/process_detector_utils.cc Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds missing required/recommended Process Entity and Process Executable Entity semantic convention attributes to the Process Resource Detector, with supporting utilities, tests, and documentation updates.

Changes:

  • Extends process detection to populate process.creation.time, process.owner, process.executable.build_id.htlhash, and process.executable.name (when available).
  • Refactors executable discovery utility to return both path + basename, and adds utilities for creation time / owner / deterministic build ID.
  • Adds unit + integration-style tests and updates the resource detector README and header docstrings accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
resource_detectors/test/process_detector_test.cc Adds new utility tests and an integration test asserting expected resource attributes are present.
resource_detectors/src/process_detector.cc Populates the new process attributes in Detect() using the new utility APIs.
resource_detectors/src/process_detector_utils.cc Implements executable info, creation time, owner lookup, and htlhash build ID computation.
resource_detectors/README.md Documents added attributes and platform limitations (notably macOS executable info).
resource_detectors/include/opentelemetry/resource_detectors/process_detector.h Updates public detector documentation to describe newly populated attributes.
resource_detectors/include/opentelemetry/resource_detectors/detail/process_detector_utils.h Declares new utility APIs (ExecutableInfo, creation time, owner, htlhash, SHA-256 helper).
Suppressed comments (1)

resource_detectors/include/opentelemetry/resource_detectors/detail/process_detector_utils.h:81

  • GetProcessOwner() has no pid parameter, but the doc comment includes an @param pid entry. This is confusing for users of this header (even under detail/).
 *
 * @param pid Process ID.
 */
std::string GetProcessOwner();

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread resource_detectors/src/process_detector_utils.cc
Comment thread resource_detectors/src/process_detector_utils.cc
Comment on lines +548 to +555
std::ifstream f(exe_path, std::ios::binary | std::ios::ate);
if (!f.is_open())
{
return std::string();
}

auto file_size = static_cast<std::uint64_t>(f.tellg());

Comment on lines +114 to 115
std::string expected_path = opentelemetry::resource_detector::detail::GetExecutableInfo(pid).path;
EXPECT_EQ(path, expected_path);
@LevelVoid

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I'm back to this now.
I've addressed the remaining feedback, fixed the MS CI issue, and updated the type/entity naming. The latest changes are ready for another look whenever you have time.

@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.

Thanks for the patch.

See a concern about the embedded SHA256 implementation.

@LevelVoid

Copy link
Copy Markdown
Contributor Author

Updated this to use openssl and removed the embedded SHA256 implementation. I've pushed the changes for another look.

@LevelVoid
LevelVoid requested a review from marcalff August 26, 2026 02:45

@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.

@LevelVoid Thanks for the changes. Adding the openssl dependency is a major change to the scope and impact of this PR (#4437 (comment)). Based on this I'm requested a change to break out the SHA256 utils and calculation of the process.executable.build_id.htlhash to a separate PR.

This PR without the process.executable.build_id.htlhash is very valuable because it still adds theprocess.creation.time (which completes the process entity identity) and the recommend attributes for process and process.executable.

@marcalff

Copy link
Copy Markdown
Member

Based on this I'm requested a change to break out the SHA256 utils and calculation of the process.executable.build_id.htlhash to a separate PR.

Yes, I agree it should be done separately.

The issue with SHA256 is not technical, it is legal: opentelemetry-cpp can not have crytographic code, even if it is stable and public.

@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.

Code depending on SHA256 should be moved in a different PR.

@LevelVoid

Copy link
Copy Markdown
Contributor Author

Got it. I'll remove the process.executable.build_id.htlhash implementation from this PR. I'll push the updates shortly.

@LevelVoid
LevelVoid requested review from dbarker and marcalff August 26, 2026 18:03

@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.

Thanks for the updates! This is a nice addition.

@LevelVoid

LevelVoid commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

@LevelVoid

Copy link
Copy Markdown
Contributor Author

@marcalff I've addressed the requested changes, and it's ready for another look.

@marcalff marcalff changed the title Add required and recommended attributes [SDK] Process resource detector reports more attributes Aug 28, 2026
@marcalff
marcalff dismissed their stale review August 28, 2026 23:18

SHA256 addressed

@marcalff marcalff changed the title [SDK] Process resource detector reports more attributes [RESOURCE] Process resource detector reports more attributes Aug 29, 2026

@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.

There is a lot of platform specific code, but this is hard to avoid.

The process resource detector is valuable for this very reason, nice work.

@marcalff
marcalff merged commit d3b1670 into open-telemetry:main Aug 29, 2026
77 checks passed
@LevelVoid

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough reviews and guidance throughout this. I learned a lot working through the platform-specific edge cases.

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] Process Entities required and recommended attributes

4 participants