|
| 1 | +--- |
| 2 | +title: Dramatiq |
| 3 | +description: "Learn how to import and use the Dramatiq integration." |
| 4 | +--- |
| 5 | + |
| 6 | +The Dramatiq integration adds support for the |
| 7 | +[Dramatiq](https://dramatiq.io/) background tasks library. |
| 8 | + |
| 9 | +<Alert level="info"> |
| 10 | + This is the successor of the original `DramatiqIntegration` that can be found here: https://github.com/jacobsvante/sentry-dramatiq |
| 11 | + |
| 12 | + The original maintainer has [donated the integration to Sentry](https://github.com/getsentry/sentry-python/issues/3387), so we can take over maintenance. |
| 13 | +</Alert> |
| 14 | + |
| 15 | +## Install |
| 16 | + |
| 17 | +To get started, install `sentry-sdk` from PyPI. |
| 18 | + |
| 19 | +```bash |
| 20 | +pip install --upgrade sentry-sdk |
| 21 | +``` |
| 22 | + |
| 23 | +## Configure |
| 24 | + |
| 25 | +Add `DramatiqIntegration()` to your `integrations` list: |
| 26 | + |
| 27 | +<SignInNote /> |
| 28 | + |
| 29 | +In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). |
| 30 | + |
| 31 | +Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. |
| 32 | + |
| 33 | +<OnboardingOptionButtons |
| 34 | + options={["error-monitoring", "performance", "profiling"]} |
| 35 | +/> |
| 36 | + |
| 37 | +```python {"onboardingOptions": {"performance": "6-8", "profiling": "9-12"}} |
| 38 | +import sentry_sdk |
| 39 | +from sentry_sdk.integrations.dramatiq import DramatiqIntegration |
| 40 | + |
| 41 | +sentry_sdk.init( |
| 42 | + dsn="___PUBLIC_DSN___", |
| 43 | + # Set traces_sample_rate to 1.0 to capture 100% |
| 44 | + # of transactions for tracing. |
| 45 | + traces_sample_rate=1.0, |
| 46 | + # Set profiles_sample_rate to 1.0 to profile 100% |
| 47 | + # of sampled transactions. |
| 48 | + # We recommend adjusting this value in production. |
| 49 | + profiles_sample_rate=1.0, |
| 50 | + integrations=[ |
| 51 | + DramatiqIntegration(), |
| 52 | + ], |
| 53 | +) |
| 54 | +``` |
| 55 | + |
| 56 | +## Verify |
| 57 | + |
| 58 | +Trigger an error in your code to verify that the integration is sending events to Sentry. |
| 59 | + |
| 60 | +```python |
| 61 | +import dramatiq |
| 62 | + |
| 63 | +import sentry_sdk |
| 64 | +sentry_sdk.init(...) # same as above |
| 65 | + |
| 66 | +@dramatiq.actor(max_retries=0) |
| 67 | +def dummy_actor(x, y): |
| 68 | + return x / y |
| 69 | + |
| 70 | +dummy_actor.send(5, 0) |
| 71 | +``` |
| 72 | + |
| 73 | +Running this will create an error event (`ZeroDivisionError`) that you should be able to see in [sentry.io](https://sentry.io). |
| 74 | + |
| 75 | +## Supported Versions |
| 76 | + |
| 77 | +- Dramatiq: 1.13+ |
| 78 | +- Python: 3.6+ |
| 79 | + |
| 80 | +<Include name="python-use-older-sdk-for-legacy-support.mdx" /> |
0 commit comments