Skip to content

Django async boundaries causing loss of Spans #4828

@landenai

Description

@landenai

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.33

Steps to Reproduce

pseudocode for the task of interest:

async def do_some_async_work():
    with sentry_sdk.start_span():  # nothing in here is being recorded right
        await baz()

    await sync_to_async(django_orm_call)(). # another complication


@shared_task
def foo_celery_task():
    with sentry_sdk.start_span():  # recorded correctly
        do_some_work()

    sync_to_async(do_some_async_work)() # not recorded

Expected Result

The spans are not seen in Sentry

Actual Result

The spans are seen in Sentry

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions