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

Eventlet monkey_patch with sentry #689

Open
Randomneo opened this issue Mar 1, 2021 · 1 comment
Open

Eventlet monkey_patch with sentry #689

Randomneo opened this issue Mar 1, 2021 · 1 comment

Comments

@Randomneo
Copy link

eventlet version: 0.30.1
sentry_sdk version: 0.20.3
greenlet version: 1.0.0

After running this code I won't get any sentry messages. If I comment monkey_patch. Then all works. I couldn't find anything about how to fix it. I saw sentry/celery page about contextvars this. But in this issue was confirmed that contextvars works fine with new greenlet. Here simple example how to reproduce it.

import eventlet
import sentry_sdk

eventlet.monkey_patch()

sentry_sdk.init('<sentry_sdk_dsn>')
sentry_sdk.capture_message('aoe')

Is there some workarounds? Or maybe I missing something?

@temoto
Copy link
Member

temoto commented Mar 1, 2021

This works.

import eventlet
eventlet.monkey_patch()

import sentry_sdk
sentry_sdk.init("dsn")
sentry_sdk.capture_message("aoe")

Quote from documentation:

It is important to call monkey_patch() as early in the lifetime of the application as possible. Try to do it as one of the first lines in the main module.

The root issue is Python allowing execution of code on import. sentry_sdk uses this mechanism to initialize some global state.

You could say sentry is important enough for a workaround. Any contribution to search more specific issue or patch is warmly welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants