-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(otel): Make sure we use correct hub on finish #7577
Conversation
} | ||
const scope = hub.getScope(); | ||
if (!scope) { | ||
__DEBUG_BUILD__ && logger.error('SentrySpanProcessor has triggered onStart before a scope has been setup.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove all of this because a hub should always be defined (and scope is actually never used anywhere).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! 🔥
size-limit report 📦
|
@@ -162,6 +145,8 @@ export class SentrySpanProcessor implements OtelSpanProcessor { | |||
|
|||
if (sentrySpan instanceof Transaction) { | |||
updateTransactionWithOtelData(sentrySpan, otelSpan); | |||
// @ts-ignore TODO: fix this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this still be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, will remove!
Fixes #7538
This one was tricky to debug...
On transactions we store the hub that called
hub.startTransaction()
. This was because we have the assumption that the hub that callsstartTransaction
will be the one that finishes it.In OpenTelemetry world this isn't the case, since our hub cloning (via domains) does not map exactly to otel context forking (via async hooks). This means async hooks might fork first, leading to the incorrect hub being used on transaction finish.
I do not want to remove the setting hub in transaction constructor, since that is needed for browser world, but to make due temporarily I added a method to override what hub is on the transaction.
The span processor then sets a new hub on finish.