Skip to content

[BUG]: Celery task_postrun warning "no existing span found" when using Task.replace() #17089

@oliverhaas-scayle

Description

@oliverhaas-scayle

Tracer Version(s)

4.3.2

Python Version(s)

3.14

Pip Version(s)

uv 0.10.8

Bug Report

When using Celery's Task.replace(), ddtrace emits a warning on every replacement:

no existing span found for task_id=<id>

This comes from trace_postrun in ddtrace/contrib/internal/celery/signals.py.

The replacement task itself runs fine and gets its own span, only the replaced (original) task triggers the warning.

This issue is probably related #11479

Reproduction Code

@shared_task(bind=True)
def sync_items(self, *, cursor: str | None = None) -> None:
    items, next_cursor = fetch_page(cursor=cursor)
    process(items)

    if next_cursor:
        self.replace(sync_items.si(cursor=next_cursor))
        return

Libraries in Use

[excerp]
"celery==5.6.2",
"ddtrace==4.3.2",

Operating System

GNU/Linux 6.12.68-92.122.amzn2023.x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions