Skip to content

Add required and recommended attributes - #4437

Open
LevelVoid wants to merge 29 commits into
open-telemetry:mainfrom
LevelVoid:add-required-attributes
Open

Add required and recommended attributes#4437
LevelVoid wants to merge 29 commits into
open-telemetry:mainfrom
LevelVoid:add-required-attributes

Conversation

@LevelVoid

Copy link
Copy Markdown

Fixes #4436

Changes

  • Add process.creation.time, process.owner, 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
Comment thread resource_detectors/src/process_detector_utils.cc
@LevelVoid

Copy link
Copy Markdown
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
Comment thread resource_detectors/src/process_detector_utils.cc

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 on lines 6 to 21
#include <fstream>
#include <string>
#include <vector>

#ifdef _MSC_VER
// clang-format off
# include <windows.h>
# include <psapi.h>
# include <shellapi.h>
# pragma comment(lib, "shell32.lib")
// clang-format on
#else
# include <sys/types.h>
# include <unistd.h>
# include <cstdio>
#endif
Comment on lines +34 to 37
* Retrieves the absolute file system path and the base name of the process executable.
* Platform-specific behavior:
* - Windows: Uses OpenProcess() + GetProcessImageFileNameW().
* - Linux/Unix: Reads the /proc/<pid>/exe symbolic link.
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
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.

@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.28571% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.80%. Comparing base (1c2b007) to head (5d5ca4c).

Files with missing lines Patch % Lines
resource_detectors/src/process_detector_utils.cc 92.35% 15 Missing ⚠️
resource_detectors/src/process_detector.cc 65.39% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4437      +/-   ##
==========================================
+ Coverage   82.67%   82.80%   +0.14%     
==========================================
  Files         516      516              
  Lines       20197    20406     +209     
==========================================
+ Hits        16696    16896     +200     
- Misses       3501     3510       +9     
Files with missing lines Coverage Δ
resource_detectors/src/service_detector_utils.cc 97.44% <100.00%> (+1.99%) ⬆️
resource_detectors/src/process_detector.cc 64.29% <65.39%> (+64.29%) ⬆️
resource_detectors/src/process_detector_utils.cc 92.24% <92.35%> (+2.96%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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 fixing the CI issues. Please see some feedback below on the process.executable.build_id.htlhash attribute value calculation.

Comment thread resource_detectors/src/process_detector_utils.cc Outdated
EXPECT_NE(attrs.find(opentelemetry::semconv::process::kProcessPid), attrs.end())
<< "process.pid must be present";

#if defined(_MSC_VER) || defined(__linux__)

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.

Can macOS be included in this check now that the executable path is populated?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes it can be, I've updated the tests, Readme and comments accordingly. The only limitation is that it can't be used for an arbitrary process id, i've documented that in the Readme. If you'd prefer, that note can be removed.

Comment thread resource_detectors/README.md Outdated
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

3 participants