Closed swantzter closed 4 months ago
you might need to use https://docs.sentry.io/platforms/node/configuration/async-context/ to do isolation, does that help?
@AbhiPrasad changing my code above to do
[snip]
Sentry.runWithAsyncContext(async () => run())
Sentry.runWithAsyncContext(async () => run())
[snip]
and also separately tried
[snip]
function run () {
Sentry.runWithAsyncContext(async () => {
[snip]
})
[snip]
and the results were.... worse:
{
level: 30,
mainSpanId: 'a5211349ba5dfebf',
mainTransactionId: '237ce9c66dcf44449ccc14afd6653b6c',
spanId: undefined,
transactionId: undefined
}
{
level: 30,
mainSpanId: '8c2e0aadea8b06ae',
mainTransactionId: '61a0aa3c86d24845968834c31756bd7f',
spanId: undefined,
transactionId: undefined
}
context was completely lost instead of just being wrong
I think we are breaking out of the async context by calling getActive...
inside the callback, we pass to build
. I think you would need to create the stream inside the same (or parent) async context as the run()
invocation.
So this should be better with 8.x
of the Node SDK. You can follow our guide to upgrade: https://docs.sentry.io/platforms/javascript/guides/express/migration/v7-to-v8/
Closing as such, but please reach out if there are issues with 8.x
of the SDK!
Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/node
SDK Version
7.88.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
Adding in a minimal repro
Steps to Reproduce
Run the code above
Expected Result
The console should log something like:
Actual Result
The current span and transaction id when processing the log line are stuck on the first transaction: