Skip to content

Should celery add a span link instead? #3002

@Kludex

Description

@Kludex

Describe your environment

Currently, the celery task that is executing gets the context from the headers, and attaches it to the new span:

token = context_api.attach(tracectx) if tracectx is not None else None
logger.debug("prerun signal start task_id=%s", task_id)
operation_name = f"{_TASK_RUN}/{task.name}"
span = self._tracer.start_span(
operation_name, context=tracectx, kind=trace.SpanKind.CONSUMER
)

I don't think this is the correct behavior. It should actually be a span link - according to the docs:

Links exist so that you can associate one span with one or more spans, implying a causal relationship. For example, let’s say we have a distributed system where some operations are tracked by a trace.

Which is exactly this case.

When a web framework triggers a celery task, it shouldn't be on the same trace. It's already a new one... But they are linked through the span link.

Would you like to implement a fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions