-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SetErrorStatusOnException option to TracerProviderSdk #1858
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1858 +/- ##
==========================================
+ Coverage 83.77% 84.06% +0.28%
==========================================
Files 187 189 +2
Lines 5967 6036 +69
==========================================
+ Hits 4999 5074 +75
+ Misses 968 962 -6
|
{ | ||
if (this.fnGetExceptionPointers() != IntPtr.Zero) | ||
{ | ||
activity.SetStatus(Status.Error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to get the type, message, and/or stack from the IntPtr returned from GetExceptionPointers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is possible by traveling through the SEH object. This is CPU/OS/platform dependent and not well documented.
https://bytepointer.com/resources/pietrek_crash_course_depths_of_win32_seh.htm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks petty intense! Not sure if it is worth attempting.
Why I bring it up:
I was just thinking about the applications I have instrumented with OpenTelemetry .NET so far. There are really only a few spots I've had the need to create spans manually. Almost exclusively around queues/topics. In those cases, I'm doing what the example has, with one exception...
catch (Exception ex)
{
activity.SetStatus(Status.Error.WithDescription(ex.Message));
throw;
}
...instead of...
catch (Exception)
{
activity.SetStatus(Status.Error);
throw;
}
So, commenting from the perspective of a user of the library, since there's only a handful of spots where I have the try/catch, and the message/description is super useful, I'll probably continue doing the try/catch instead of using the processor/option. But if the processor could grab the message too, that would be something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to cover it in a follow up PR.
One heads up, the exceptions we captured here could be any SEH exception - e.g. C++ exception, OS exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using #1874 to explore how deep should we go.
@@ -0,0 +1,71 @@ | |||
# Exception Handling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ this guide 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
|
||
A complete example can be found [here](./Program.cs). | ||
|
||
Note: this feature is platform dependent as it relies on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the doc it looks like its support in all cases except in .NET Core 2.1.
Do you know if it works in windows only?
While we can generally redirect users to official docs, we can list any obvious things right here in this doc . for example, if this only works in Windows, we can mention it here (along with link to official doc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works on Mac (x64) and Linux (x86 VM) as I've tested locally (I also created issue #1859 to cover ARM64).
This reverts commit 9bf74a3.
Related to #1853.
Changes
TracerProviderOptions
to allow configurations while creating the tracer provider. Inspired by @CodeBlanch per offline discussion.ExceptionProcessor
based on the idea from Automatically detect exceptions and set Activity status #1853.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes