Dramatiq for Python

Learn how to import and use the Dramatiq integration.

The Dramatiq integration adds support for the Dramatiq background tasks library.

The Dramatiq integration only reports errors. Tracing is not yet supported. If you want to have more instrumentation, you need to do custom instrumentation.

This is the successor of the original DramatiqIntegration that can be found here: https://github.com/jacobsvante/sentry-dramatiq

The original maintainer has donated the integration to Sentry, so we can take over maintenance.

To get started, install sentry-sdk from PyPI.

pip install "sentry-sdk"

Add DramatiqIntegration() to your integrations list:

import sentry_sdk
from sentry_sdk.integrations.dramatiq import DramatiqIntegration

sentry_sdk.init(
    dsn="___PUBLIC_DSN___",
    # Check https://docs.sentry.io/platforms/python/data-management/data-collected/ to configure what data is collected
    data_collection={
        "user_info": True,
    },
    integrations=[
        DramatiqIntegration(),
    ],
)

Trigger an error in your code to verify that the integration is sending events to Sentry.

import dramatiq

import sentry_sdk
sentry_sdk.init(...)  # same as above

@dramatiq.actor(max_retries=0)
def dummy_actor(x, y):
    return x / y

dummy_actor.send(5, 0)

Running this will create an error event (ZeroDivisionError) that you should be able to see in sentry.io.

  • Dramatiq: 1.9+
  • Python:
    • 3.6+ (SDK <3.0)
    • 3.7+ (SDK 3.0+)

If you're looking to use Sentry with older Python or framework versions, consider using an older major version of the SDK. The minimum versions for each major version are listed above.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").