ARQ

The ARQ integration adds support for the ARQ Job Queue System.

Install sentry-sdk from PyPI with the arq extra.

Copied
pip install --upgrade "sentry-sdk[arq]"

Add ArqIntegration() to your integrations list and make sure that tracing is enabled:

Copied
import sentry_sdk
from sentry_sdk.integrations.arq import ArqIntegration

sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
    enable_tracing=True,
    integrations=[
        ArqIntegration(),
    ],
)

Copied
import asyncio

from arq import create_pool
from arq.connections import RedisSettings

async def main():
    sentry_sdk.init(...)  # same as above
    redis = await create_pool(RedisSettings())

    with sentry_sdk.start_transaction(name="testing_sentry"):
        r = await redis.enqueue_job("add_numbers", 1, 2)

asyncio.run(main())

When you run run.py it will create a transaction called testing_sentry in the Performance section of sentry.io, and create a span for enqueing the job.

It takes a couple of moments for the data to appear in sentry.io.

Copied
import sentry_sdk
from sentry_sdk.integrations.arq import ArqIntegration

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

async def add_numbers(ctx, a, b):
    1/0 # raises an error!
    return a + b

class WorkerSettings:
    functions = [add_numbers]

When you run a worker with arq demo.WorkerSettings it will create a transaction called add_numbers in the Performance section of sentry.io, and will also create and issue in Sentry and connect it to the transaction.

It takes a couple of moments for the data to appear in sentry.io.

  • ARQ: 0.23+
  • Python: 3.7+
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").