Skip to content

Eventlet monkey_patch with sentry #689

Open

Description

@Randomneo

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?

Activity

  1. temoto commented on Mar 1, 2021

    @temoto
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions