Skip to content
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

fix(tracing): Fix celery custom headers propagation #20996

Merged
merged 1 commit into from Sep 28, 2020

Conversation

beezz
Copy link
Contributor

@beezz beezz commented Sep 25, 2020

This fixes the broken propagation of Celery custom headers that are used by our distributed tracing.

The bug seems to be in Celery worker Request class which is not propagating the request headers properly (self._request_dict["headers"]).

When the task is later executed using Request.execute_using_pool, message.headers is not passed (nor message) which makes me think it's a bug since this way message.headers are completely ignored.

I'm opening this PR here to illustrate the issue so we can decide how to properly fix it upstream and in sentry-sdk.

@untitaker
Copy link
Member

so I guess what I am confused about is why the sdk testsuite passes? There is one test that tests this against the Redis backend with a real Worker that forks.

Is this reproducible with redis and rabbitmq?

@beezz
Copy link
Contributor Author

beezz commented Sep 25, 2020

I don't think this is specific to a backend but I will check the sdk tests.

@beezz
Copy link
Contributor Author

beezz commented Sep 25, 2020

Tests are passing because they always use the Celery proto2 and here it makes headers=message.headers. See https://github.com/celery/celery/blob/master/celery/worker/strategy.py#L132-L135

If I instruct the test with Redis to use celery.conf.task_protocol=1 it fails.

Sentry is using task_protocol=1 ~ https://github.com/getsentry/sentry/blob/master/src/sentry/conf/server.py#L502

@untitaker untitaker merged commit be2f2be into master Sep 28, 2020
@untitaker untitaker deleted the fix/celery-trace-propagation branch September 28, 2020 08:13
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants