Skip to content

Arq integration fails when worker setting is dict #3741

@saber-solooki

Description

@saber-solooki

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.17.0

Steps to Reproduce

According to the arq implementation it is a common case to define Wroker Settings either as class (the protocol for that is WorkerSettingsBase) or dict. We have defined many worker settings in our services which all of them are based on dict and I noticed that I can't catch the exception in the sentry console although I could see "POST /api/1811479/envelope/ HTTP/11" 200" message in debug mode.

So to make it more clear you can test it like this:
Script to enqueue a jon:

import asyncio

import sentry_sdk
from arq import create_pool
from arq.connections import RedisSettings


async def main():
    sentry_sdk.init(dsn='DSN_SAMPLE, traces_sample_rate=1.0, profiles_sample_rate=1.0)
    redis = await create_pool(RedisSettings())
    await redis.enqueue_job("add_numbers", a=1, b=2)

asyncio.run(main())

And the worker sample:

import sentry_sdk

sentry_sdk.init(dsn='DSN_SAMPLE', traces_sample_rate=1.0, profiles_sample_rate=1.0)

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

# This one works
class WorkerSettings:
    functions = [add_numbers]

# This one doesn't work
WorkerSettings = {
    "functions": [add_numbers]
}

PS:
I've already prepared a fix PR. So please review 🙏

Expected Result

To see exceptions in the sentry console when an exception happens in arq job

Actual Result

I can't catch any exceptions in the sentry console

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions