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

Threads mistakenly attach to main thread's span #674

Open
Ten0 opened this issue Jul 25, 2024 · 4 comments
Open

Threads mistakenly attach to main thread's span #674

Ten0 opened this issue Jul 25, 2024 · 4 comments

Comments

@Ten0
Copy link
Contributor

Ten0 commented Jul 25, 2024

The first time we call sentry-related functions in a thread, it attaches to whichever Span the main thread is currently attached to.
This causes very wrong sub-spanning (which I just spend 6 hours investigating).
Attaching to sentry client, DSN, parameters..., etc seems correct, but span definitely not.

I feel like maybe the Scope should be a property that's not inherited from whichever scope the main thread happens to be in at that moment, because if there is a sub-thread it's very possible that the main thread is doing unrelated work at that moment, and that unrelated work may very well involve its own spans and data, so it seems that it's not correct to attach to those.

Related issues: #507
Related writeup: https://swatinem.de/blog/log-contexts/

@Ten0

This comment has been minimized.

@Ten0

This comment has been minimized.

@Ten0

This comment has been minimized.

@Ten0
Copy link
Contributor Author

Ten0 commented Jul 25, 2024

Ok so my understanding is that there's no way to prevent the Hub to attach to the current scope of the main thread.
It looks like the "main Hub" shouldn't really be attached to any thread, and even the main thread should have its own Hub.
That would fix this issue.

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

No branches or pull requests

1 participant