-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat: add example using Sentry V2 SDK #140
base: main
Are you sure you want to change the base?
Conversation
Notes: The V1 example doesn't seem to work for me after recently trying to set up Sentry. The issue seems to be related to the `warnings` and `threading` modules that Sentry uses not being included properly into the Temporal Workflow's sandbox. This results in the Workflow execution failing to start in the worker that handles the Workflow. I don't see any issues with the Sentry interceptor on other workers that only handle activities, so it is definitely related to the Workflow sandbox. Note: I also tried disabling the worker's sandbox and this seemed to work, even though you get a sporadic error in the Temporal UI. The solution seems to be to migrate the interceptor to use V2 of Sentry's SDK, where the Hub object is now deprecated in favour of using scopes. It seems that using the scope context manager doesn't have the same issues with the warnings and threading libs (which it does still use). I've created a new example to keep the V1 example in place, since V2 only works with Python 3.6 or above.
|
Note: This is a small modification of the original example [sentry (v1)](../sentry) which seems to have | ||
issues in the Workflow interceptor, as there are modules (`warnings` and `threading`) that Sentry uses that aren't passed through | ||
to Temporal's sandbox properly, causing the Workflows to fail to execute. |
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.
If Sentry V1 doesn't work anymore, let's replace the sample instead of adding a new one
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.
Hey @cretz - I haven't been able to test this, but I suspect now the example didn't work for me because when I installed sentry-sdk, it will have defaulted to the latest version (V2), but the example only works with V1. I imagine if you pin the version to the one in the example, it might work.
It does look like development on the V1 SDK has stopped now (last feature release was in April with a security patch in July).
So, I will let you decide if we should replace the V1 example. I'll update the PR as necessary.
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.
Hrmm, assuming the current sentry
works, how about we just move the current one to sentry_v1
and make yours just sentry
? So change the dirs and the dependency group name and the top-level README and such. Then we can come back and delete sentry_v1
later when they officially EOL it.
issues in the Workflow interceptor, as there are modules (`warnings` and `threading`) that Sentry uses that aren't passed through | ||
to Temporal's sandbox properly, causing the Workflows to fail to execute. | ||
|
||
> Sentry V2 only supports Python 3.6 and higher. So if you're on Python 3.5, you may need to refer to the original example |
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.
Temporal Python SDK only supports 3.8 or higher, so this disclaimer is not needed
What was changed
Added a new example to set up Sentry using the V2 SDK.
Why?
After recently trying to set up Sentry, the existing example that uses Sentry's V1 SDK doesn't work for me. The issue seems to be related to the
warnings
andthreading
modules that Sentry uses not being appropriately included in the Temporal Workflow's sandbox. This results in the Workflow execution failing to start in the worker that handles the Workflow. I don't see any issues with the Sentry interceptor on other workers that only handle activities, so it seems the problem is related to the Workflow sandbox.Note: I also tried disabling the worker's sandbox, which seemed to get further. The workflow is able to start and eventually finish, but you get a sporadic error in the workflow's event history.
The solution is to migrate the interceptor to use V2 of Sentry's SDK, where the Hub object is now deprecated in favour of using scopes. Using the scope context manager doesn't seem to have the same issues with the warnings and threading libs (which it still uses).
I've created a new example to keep the V1 example in place, since V2 only works with Python 3.6 or above.
Checklist
https://temporalio.slack.com/archives/CTT84RS0P/p1725394300914329
Tested manually in my application using Sentry.io
Added a new example with a README explaining the reasons/difference between the original example and the v2 example.