Skip to content

Conversation

@thompson-tomo
Copy link
Contributor

@thompson-tomo thompson-tomo commented Oct 28, 2025

Fixes #2892
Design discussion issue #

Changes

This adds in additional recommend attributes to describe process. Implementation has been based on latest spec https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/process.md

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added the comp:resources.process Things related to OpenTelemetry.Resources.Process label Oct 28, 2025
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.50%. Comparing base (b2ff815) to head (247870d).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...OpenTelemetry.Resources.Process/ProcessDetector.cs 78.94% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3347      +/-   ##
==========================================
- Coverage   70.79%   69.50%   -1.29%     
==========================================
  Files         440      386      -54     
  Lines       17265    15581    -1684     
==========================================
- Hits        12222    10829    -1393     
+ Misses       5043     4752     -291     
Flag Coverage Δ
unittests-Extensions.Enrichment.AspNetCore ?
unittests-Extensions.Enrichment.Http ?
unittests-Instrumentation.Cassandra ?
unittests-OpAmp.Client ?
unittests-Resources.Process 85.71% <78.94%> (-14.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...OpenTelemetry.Resources.Process/ProcessDetector.cs 84.61% <78.94%> (-15.39%) ⬇️

... and 135 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thompson-tomo thompson-tomo changed the title Feature/#2892 implement recomended process attr implement latest semconv spec for process resource #2892 Oct 28, 2025
@thompson-tomo thompson-tomo marked this pull request as ready for review October 28, 2025 10:23
@thompson-tomo thompson-tomo requested a review from a team as a code owner October 28, 2025 10:23
Comment on lines 22 to 26
new(ProcessSemanticConventions.AttributeProcessStartTime, currentProcess.StartTime.ToString("O") ?? string.Empty),
new(ProcessSemanticConventions.AttributeProcessTitle, currentProcess.MainWindowTitle),
new(ProcessSemanticConventions.AttributeProcessWorkingDir, Environment.CurrentDirectory),

new(ProcessSemanticConventions.AttributeProcessExecName, currentProcess.ProcessName),
Copy link
Contributor

Choose a reason for hiding this comment

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

Some process related properties may throw exceptions. For example, StartTime throws 3 exceptions, and there is likely no way to detect errors like Win32Exception ahead of time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the exceptions the only one we are interested in is win32 so have added a try catch and also exited earlier if process has exited.

The others are for scenarios we don't support ie windows 98.

The current directory does through a number of exceptions but they are for the set method which is not used.

Comment on lines +46 to +51
attributes.Add(new(ProcessSemanticConventions.AttributeProcessStartTime, currentProcess.StartTime.ToString("O") ?? DateTime.Now.ToString("O")));
}
#endif
catch (Win32Exception)
{
attributes.Add(new(ProcessSemanticConventions.AttributeProcessStartTime, DateTime.Now.ToString("O")));
}
Copy link
Member

Choose a reason for hiding this comment

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

Fallbacks here are not true IMO. If you are not detect attributes, just omit it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about that but in the case here creation time is an identifying attribute and all identifying should actually be required hence open-telemetry/weaver#986 to address it.

Also Using The current time enables the functionality of distinguishing between telemetry from process starts, leaving it out you lose that.

Copy link
Member

Choose a reason for hiding this comment

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

Lack of the data is better than the wrong data.

Copy link
Contributor Author

@thompson-tomo thompson-tomo Nov 4, 2025

Choose a reason for hiding this comment

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

Are you saying that all the process entity attributes should be omitted if the creation time can not be set given it is an identifying attribute?

For me the exact value of the atrribute is not as meaningful as having a value there which can then be used to achieve the use case.

Copy link
Member

Choose a reason for hiding this comment

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

I am not against keeping part of the attributes. Part of data seems to be fine. I am against putting obviously wrong data in the attributes/any other signal.

In this case, add this attribute conditionally if it is available. You can document it properly in the README. Small deviations from the semantics should be allowed if we have technical blockers for implementation.

Comment on lines +46 to +51
attributes.Add(new(ProcessSemanticConventions.AttributeProcessStartTime, currentProcess.StartTime.ToString("O") ?? DateTime.Now.ToString("O")));
}
#endif
catch (Win32Exception)
{
attributes.Add(new(ProcessSemanticConventions.AttributeProcessStartTime, DateTime.Now.ToString("O")));
}
Copy link
Member

Choose a reason for hiding this comment

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

Lack of the data is better than the wrong data.

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 12, 2025
@github-actions github-actions bot removed the Stale label Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:resources.process Things related to OpenTelemetry.Resources.Process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] update process resource detectors

4 participants