-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Celery publish from celery creating separate traces #609
Comments
This issue was marked stale due to lack of activity. It will be closed in 30 days. |
Any news with this one that is problematic for celery usage. |
I don't think there is any work around here other than fixing the bug. |
@owais, @lonewolf3739 Workaround It would be suffice to add for example:
Now, if the workaround is ok, we can update the documentation. @owais another thing is the |
SpanKind should definitely NOT be SERVER. This looks like a limitation in the APM backend you are using. I don't think users should have to worry about the workaround. Ideally, instrumenting with Otel should require zero code changes especially to existing non-otel related code. IMO this is a bug in the Celery instrumentation and should be fixed so it works for all users. |
@owais - I run into this issue and wondering what the right fix is. |
@blumamir You might want to check this proposed WIP fix by a contributor goatsthatcode#1. I think there are multiple Github issues created for this same problem. |
Thanks! I commented on the PR |
Describe your environment
python==3.7.4/3.7.6
Platform==Local - MacOS(Darwin-20.5.0-x86_64-i386-64bit), Remote - Linux (many distros)
Otel release==0.22b0 (verified on OTEL main as well - same code and same behavior)
Steps to reproduce
When running two celery apps where one uses another, when instrumenting the celery apps with OpenTelemetry, the second celery worker creates a span within a separate trace from the first one.
Reproduction example:
otel_celery_first.py
otel_celery_second.py
test_celery.py
Running the workers:
celery -A otel_celery_first worker -n first@%h -Q first
celery -A otel_celery_second worker -n second@%h -Q second
Sending the task:
python test_celery.py
What is the expected behavior?
Two spans, with the same trace ID.
First celery worker output:
Second celery worker output:
What is the actual behavior?
Two spans, with a different trace ID for each:
First celery worker output:
Second celery worker output:
I would expect a span of
apply_async
which is also missing from the first worker.Additional context
I believe this has got to do with the
_trace_before_publish
signal handler:The task is tried to be retrieved from the celery registry by the sender name, which is the task name that we send to. But, the first worker does not explicitly declare the tasks it sends as part of its registry, so the task is not found and thus returns None which causes the function to exit prematurely. Perhaps there's a better to way to handle this?
The text was updated successfully, but these errors were encountered: