samples-python
samples-python copied to clipboard
[Bug] Sentry python sdk not working anymore
What are you really trying to do?
I was trying to use the sentry sdk sample but it does not work anymore because it indirectly uses the warning module.
Describe the bug
The with Hub(Hub.current) context manager triggers an import of the warning module because hub is being deprecated and there is an import-time warning about that.
I am not exactly sure why the passthrough is not enough, I just started using temporal :)
Minimal Reproduction
Use a sentry recent version (mine was 2.22.0)
Set up the sample, trigger a workflow.
It fails.
Additional context
I was able to fix by replacing with Hub(Hub.current) with with isolation_scope()
I wonder if to avoid future issue there is a way to handle some non-available lib in the sandbox directly? To have calling warnings for instance do nothing instead of failing ?
I'm having the same issue an update to the sentry code, would temporal consider adding an officially supported integration instead of a recipe?
Yes, same question. Having to copy/paste this Python file from the repo and update it when it breaks is a bit strange to manage. Would a contrib module with different extras like temporalio-contrib[sentry,pydantic] (etc.) be a better idea ? I posted it there after seeing @NorthIsUp’s comment, but maybe we should open a new issue for that .
We can discuss formal inclusion in the SDK though that is a bit of a larger ask. In the meantime, this sample was an external contribution and unfortunately did not have tests. So I think the best first step is to add tests to make sure it works and continues to work. We do have plans to address this issue hopefully soon (but we also accept PRs of course). EDIT: And we also need to move the workflow to its own file that does no sentry imports.
@cretz appreciate that, temporal and sentry are both critical tools to our operational infrastructure and we would love for the two tool to play nice!
If I understand correctly, the fix is to move the captureException code within an activity so that it is not tampered with the workflow_sandbox importer.
Had anyone have a look at https://github.com/temporalio/samples-python/pull/140 ?
This issue should be solved now that #140 is merged