-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle case where
SetException
throws (#5291)
- Loading branch information
1 parent
832de4b
commit 7be52af
Showing
1 changed file
with
17 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,17 +405,25 @@ internal void SetExceptionTags(Exception exception) | |
{ | ||
if (exception != null) | ||
{ | ||
// for AggregateException, use the first inner exception until we can support multiple errors. | ||
// there will be only one error in most cases, and even if there are more and we lose | ||
// the other ones, it's still better than the generic "one or more errors occurred" message. | ||
if (exception is AggregateException aggregateException && aggregateException.InnerExceptions.Count > 0) | ||
try | ||
{ | ||
exception = aggregateException.InnerExceptions[0]; | ||
} | ||
// for AggregateException, use the first inner exception until we can support multiple errors. | ||
// there will be only one error in most cases, and even if there are more and we lose | ||
// the other ones, it's still better than the generic "one or more errors occurred" message. | ||
if (exception is AggregateException aggregateException && aggregateException.InnerExceptions.Count > 0) | ||
{ | ||
exception = aggregateException.InnerExceptions[0]; | ||
} | ||
|
||
SetTag(Trace.Tags.ErrorMsg, exception.Message); | ||
SetTag(Trace.Tags.ErrorStack, exception.ToString()); | ||
SetTag(Trace.Tags.ErrorType, exception.GetType().ToString()); | ||
SetTag(Trace.Tags.ErrorMsg, exception.Message); | ||
SetTag(Trace.Tags.ErrorType, exception.GetType().ToString()); | ||
SetTag(Trace.Tags.ErrorStack, exception.ToString()); | ||
} | ||
catch (Exception ex) | ||
{ | ||
// We have found rare cases where exception.ToString() throws an exception, such as in a FileNotFoundException | ||
Log.Warning(ex, "Error setting exception tags on span {SpanId} in trace {TraceId}", SpanId, TraceId); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
andrewlock
Author
Member
|
||
} | ||
} | ||
} | ||
|
||
|
We should use
TraceId128
instead ofTraceId
to include the full 128-bit trace id.