Connect RQ to Bugsink
When an RQ job fails, Bugsink shows the exception, the worker-side Python stack, and the function the worker was running.
This guide adds error reporting to an existing RQ worker and queues a deliberate failure through Redis. You will confirm that the job follows RQ’s normal failed job path while its exception reaches Bugsink automatically.
To follow along, create a Bugsink project and copy its DSN. The quickstart guide shows where to find it.
Install the SDK
Install the open-source Sentry Python SDK with its RQ support in the environment used by your worker. Bugsink accepts the SDK’s event protocol, so it can send failed jobs directly to your Bugsink project:
python -m pip install --upgrade 'sentry-sdk[rq]'python -m pip install --upgrade 'sentry-sdk[rq]'
Configure the worker
Initialize the SDK in the settings module that RQ imports when the worker
starts. Enabling RqIntegration patches the worker lifecycle before it begins
processing jobs; the job function itself does not need a reporting call:
import os import sentry_sdk from sentry_sdk.integrations.rq import RqIntegration :::python sentry_sdk.init( dsn=os.environ["SENTRY_DSN"], integrations=[RqIntegration()], )import os import sentry_sdk from sentry_sdk.integrations.rq import RqIntegration :::python sentry_sdk.init( dsn=os.environ["SENTRY_DSN"], integrations=[RqIntegration()], )
Keep the queue and Redis settings in the same module if your worker already loads them there:
import os import sentry_sdk from sentry_sdk.integrations.rq import RqIntegration sentry_sdk.init( dsn=os.environ["SENTRY_DSN"], integrations=[RqIntegration()], ) REDIS_URL = os.environ.get("REDIS_URL", "redis://127.0.0.1:6379/0") QUEUES = ["inventory"]import os import sentry_sdk from sentry_sdk.integrations.rq import RqIntegration sentry_sdk.init( dsn=os.environ["SENTRY_DSN"], integrations=[RqIntegration()], ) REDIS_URL = os.environ.get("REDIS_URL", "redis://127.0.0.1:6379/0") QUEUES = ["inventory"]
Set SENTRY_DSN in the worker’s environment to the DSN shown by your Bugsink
project:
export SENTRY_DSN=https://key@bugsink.example/1export SENTRY_DSN=https://key@bugsink.example/1
Queue a job that fails
An RQ job needs no Bugsink-specific code. When the function raises and RQ moves
the job to its failed-job registry, the integration reports the exception from
the worker. This inventory job raises ProductNotFound for an unknown product:
def reserve_product(sku, quantity=1): try: product = INVENTORY[sku] except KeyError: raise ProductNotFound(f"Product {sku} is not in inventory") from None if product["stock"] < quantity: raise ValueError(f"Only {product['stock']} units of {sku} are available") return { "sku": sku, "name": product["name"], "reserved": quantity, }def reserve_product(sku, quantity=1): try: product = INVENTORY[sku] except KeyError: raise ProductNotFound(f"Product {sku} is not in inventory") from None if product["stock"] < quantity: raise ValueError(f"Only {product['stock']} units of {sku} are available") return { "sku": sku, "name": product["name"], "reserved": quantity, }
Start your worker with its normal settings module:
rq worker -c inventory_worker.worker_settingsrq worker -c inventory_worker.worker_settings
Queue the job from another process. This example’s producer uses the same Redis
URL and puts the reservation on the inventory queue:
python -m inventory_worker.enqueue rq-missingpython -m inventory_worker.enqueue rq-missing
The worker logs the unhandled ProductNotFound, and RQ retains the job as
failed.
See the failed job in Bugsink
Open your Bugsink project and select the new ProductNotFound issue. Its event
points to the job body and names the function RQ executed.
ProductNotFound
That’s it: failed RQ jobs will now be reported to Bugsink. The integration runs inside the worker, so producers do not need to catch job failures or wait for a result in order to report them.
Limitations
The SDK filters RQ job arguments and keyword arguments by default. The event still contains the job function, generated job ID, exception, and worker stack. This keeps the useful failure identity without automatically sending the values passed to every background job.
RQ needs Redis for its normal queue lifecycle; the SDK does not add another service. Use the same Redis configuration and worker process you already run.
For handled exceptions, logging, tags, structured context, and other SDK options, continue with the broader Python guide.
