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

feat(celery): Allow to override propagate_traces per task #2331

Merged
merged 9 commits into from Sep 6, 2023

Conversation

jan-auer
Copy link
Member

@jan-auer jan-auer commented Aug 30, 2023

Adds support for a sentry-propagate-traces header on apply_async that
overrides the default behavior set through the Celery integration's
propagate_traces flag.

Example usage:

my_task.apply_async(..., headers={"sentry-propagate-traces": False})

Example use case:
We ourselves have a task that is running once every two weeks and it is sampled with ~0.01 Percent. So we can one transaction from this task a year (give or take). This task starts hundreds of child tasks. All those child tasks will inherit the sampling decision from the original task and thus will be dropped most of the times. But we want to have those child tasks transactions in our backend no matter the sampling decision of the parent.

Documentation PR: getsentry/sentry-docs#7757

@antonpirker
Copy link
Member

Documentation PR: getsentry/sentry-docs#7757

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, left a small suggestion

sentry_sdk/integrations/celery.py Show resolved Hide resolved
sentry_sdk/integrations/celery.py Outdated Show resolved Hide resolved
sentry_sdk/integrations/celery.py Outdated Show resolved Hide resolved
@antonpirker
Copy link
Member

Diff looks now ugly, but code is way more readable! 💯

@antonpirker antonpirker merged commit 4f773a1 into master Sep 6, 2023
245 of 246 checks passed
@antonpirker antonpirker deleted the feat/celery-manual-propagate-traces branch September 6, 2023 11:58
sentrivana pushed a commit that referenced this pull request Sep 18, 2023
Adds support for a sentry-propagate-traces header on apply_async that
overrides the default behavior set through the Celery integration's
propagate_traces flag.

Example usage:

my_task.apply_async(..., headers={"sentry-propagate-traces": False})

Example use case:
We ourselves have a task that is running once every two weeks and it is sampled with ~0.01 Percent. So we can one transaction from this task a year (give or take). This task starts hundreds of child tasks. All those child tasks will inherit the sampling decision from the original task and thus will be dropped most of the times. But we want to have those child tasks transactions in our backend no matter the sampling decision of the parent.
---------

Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants