Skip to content
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

[WIP] Automatically get exception message and set to Span.Status #1874

Closed
wants to merge 7 commits into from

Conversation

reyang
Copy link
Member

@reyang reyang commented Mar 7, 2021

This is a follow up to the previous PR comment.
To play with the current code, use docs\trace\exception-handling> dotnet run --framework net5.0.

Current thinking:

  1. Examine the EXCEPTION_RECORD.ExceptionCode, if code is 0xE0434352, proceed to step 2, otherwise exit since it is not a CLR Exception.
  2. Examine if side-by-side CLR is enabled, and if yes, check if the exception belongs to the current CLR module?
  3. Extract the EXCEPTION_RECORD, fetch the System.Exception object (might need to pin the object on GC?).
  4. Access the exception object's detail via field or method call.
  5. Unpin the exception object? (if pinned on step 2)

Reference:

@reyang reyang requested a review from a team March 7, 2021 00:30
@reyang reyang changed the title More exceptions [WIP] More exceptions Mar 7, 2021
@reyang reyang closed this Mar 7, 2021
@reyang reyang reopened this Mar 7, 2021
@reyang reyang marked this pull request as draft March 7, 2021 00:33
@codecov
Copy link

codecov bot commented Mar 7, 2021

Codecov Report

Merging #1874 (07fd41a) into main (cb066cb) will decrease coverage by 0.40%.
The diff coverage is 79.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1874      +/-   ##
==========================================
- Coverage   83.77%   83.36%   -0.41%     
==========================================
  Files         187      188       +1     
  Lines        5967     6139     +172     
==========================================
+ Hits         4999     5118     +119     
- Misses        968     1021      +53     
Impacted Files Coverage Δ
src/OpenTelemetry/Sdk.cs 100.00% <ø> (ø)
src/OpenTelemetry/Logs/OpenTelemetryLogger.cs 26.82% <20.54%> (-44.60%) ⬇️
src/OpenTelemetry/Logs/LogRecord.cs 82.50% <77.77%> (-5.00%) ⬇️
.../OpenTelemetry/Logs/OpenTelemetryLoggerProvider.cs 77.55% <88.23%> (+7.09%) ⬆️
...rc/OpenTelemetry/Trace/TracerProviderBuilderSdk.cs 89.83% <91.66%> (-0.92%) ⬇️
src/OpenTelemetry/Trace/ExceptionProcessor.cs 93.75% <93.75%> (ø)
src/OpenTelemetry/Trace/TracerProviderSdk.cs 95.16% <98.64%> (+4.38%) ⬆️
...metryProtocol/Implementation/ActivityExtensions.cs 86.89% <100.00%> (+0.05%) ⬆️
...ry.Instrumentation.AspNet/AspNetInstrumentation.cs 100.00% <100.00%> (ø)
...umentation.AspNet/Implementation/HttpInListener.cs 89.10% <100.00%> (ø)
... and 22 more


switch (exceptionRecord.ExceptionCode)
{
case EXCEPTION_CODE.EXCEPTION_COMPLUS:
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

}

activity.SetTag("exceptionRecord.NumberParameters", exceptionRecord.NumberParameters);
activity.SetTag("exceptionRecord.ExceptionInformation", exceptionRecord.ExceptionInformation);
Copy link
Member Author

@reyang reyang Mar 7, 2021

Choose a reason for hiding this comment

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

Copy link
Member Author

@reyang reyang Mar 7, 2021

Choose a reason for hiding this comment

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

ExceptionInformation[4] has different meaning depending on the condition compilation - related to side-by-side.

Copy link
Member Author

Choose a reason for hiding this comment

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

!sos.pe might give some clue, worst case is that the logic is duplicated in mscordacwks.dll...

// exceptionRecord.ExceptionInformation[2] == 0
// exceptionRecord.ExceptionInformation[3] == 0

var pClrModuleBase = exceptionRecord.ExceptionInformation[4];
Copy link
Member Author

Choose a reason for hiding this comment

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

This points to the base image address of clr.dll or coreclr.dll.

@reyang reyang force-pushed the reyang/exception branch from a490d3c to a115219 Compare March 8, 2021 18:25
@reyang reyang changed the title [WIP] More exceptions [WIP] Automatically get exception message and set to Span.Status Mar 12, 2021
@reyang reyang closed this Sep 18, 2021
@reyang reyang deleted the reyang/exception branch September 18, 2021 02:22
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.

1 participant