Add SetErrorStatusOnException option to TracerProviderSdk#1858
Add SetErrorStatusOnException option to TracerProviderSdk#1858cijothomas merged 24 commits intomainfrom
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.
Is it possible to get the type, message, and/or stack from the IntPtr returned from GetExceptionPointers?
There was a problem hiding this comment.
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.
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.
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.
I'm using #1874 to explore how deep should we go.
| @@ -0,0 +1,71 @@ | |||
| # Exception Handling | |||
|
|
||
| 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.
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.
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
TracerProviderOptionsto allow configurations while creating the tracer provider. Inspired by @CodeBlanch per offline discussion.ExceptionProcessorbased 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.mdupdated for non-trivial changes