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

Node ANR tracking not getting trace context attached #9324

Closed
3 tasks done
AbhiPrasad opened this issue Oct 20, 2023 · 4 comments · Fixed by #9823
Closed
3 tasks done

Node ANR tracking not getting trace context attached #9324

AbhiPrasad opened this issue Oct 20, 2023 · 4 comments · Fixed by #9823
Assignees
Labels

Comments

@AbhiPrasad
Copy link
Member

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

7.74.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

Reported by @ollipa as part of #9307

  1. Enable ANR tracking
  2. Create ANR error

Expected Result

You should see a trace context on the ANR error

Actual Result

No trace context 😢

@timfish
Copy link
Collaborator

timfish commented Nov 30, 2023

A couple of thoughts on this:

  • In a server app with multiple in-flight requests, there will likely be multiple trace contexts in the app process when the blocking is detected in the ANR process. We might be able to access the offending trace context via the debugger interface if it's stored on the global scope. This is assuming the debugger respects the AsyncLocalStorage boundaries 🤔
  • If the main process event loop is blocked indefinitely, Sentry will not send any more envelopes so will attaching the trace context to the ANR event be of any use?

@timfish
Copy link
Collaborator

timfish commented Dec 4, 2023

It looks like we can get the trace id via the debugger from the global:

__SENTRY__.hub._stack[0].scope._propagationContext.traceId

image

@AbhiPrasad
Copy link
Member Author

Yeah we should apply trace id from propagation context - I wonder why it's not done with captureEvent 🤔

@timfish
Copy link
Collaborator

timfish commented Dec 5, 2023

ANR events are captured and sent from the independent ANR process where we don't have the context. We can't rely on sending events from the main app process because the event loop could be blocked indefinitely.

It looks like we might be able to grab the trace context from the app process via the debugger in much the same way that we read variables in the LocalVariables integration. Rather than read the local stack variables, we can read the global variables at the time of the debugger pause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants