fix(worker): Remove Sentry re-initialization in forked workers#680
Open
drazisil-codecov wants to merge 2 commits intomainfrom
Open
fix(worker): Remove Sentry re-initialization in forked workers#680drazisil-codecov wants to merge 2 commits intomainfrom
drazisil-codecov wants to merge 2 commits intomainfrom
Conversation
Removes the `initialize_sentry_for_worker_process` signal handler that was calling `sentry_sdk.init()` again in each forked worker process. We believe this may be breaking CeleryIntegration's `build_tracer` patch - calling init() a second time in child processes could interfere with the patches that were already applied in the parent process before fork. Investigation findings: - Staging (Dec 17, 2025 code without this handler) has working worker traces - Production (with this handler) has zero worker transactions in Sentry - Trace analysis shows API spans but no worker spans in production - Diagnostic check showed `build_tracer patched: False` in production The parent process's Sentry initialization (via `celeryd_init` signal in app.py) should be inherited by forked children, so re-initialization may not be needed. Relates to: CCMRG-2037
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #680 +/- ##
=======================================
Coverage 92.43% 92.43%
=======================================
Files 1297 1297
Lines 47730 47725 -5
Branches 1606 1606
=======================================
- Hits 44119 44116 -3
+ Misses 3302 3300 -2
Partials 309 309
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
jason-ford-codecov
approved these changes
Feb 2, 2026
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 2, 2026
Removes the `initialize_sentry_for_worker_process` signal handler that was calling `sentry_sdk.init()` again in each forked worker process. We believe this may be breaking CeleryIntegration's `build_tracer` patch - calling init() a second time in child processes could interfere with the patches that were already applied in the parent process before fork. Investigation findings: - Staging (Dec 17, 2025 code without this handler) has working worker traces - Production (with this handler) has zero worker transactions in Sentry - Trace analysis shows API spans but no worker spans in production - Diagnostic check showed `build_tracer patched: False` in production The parent process's Sentry initialization (via `celeryd_init` signal in app.py) should be inherited by forked children, so re-initialization may not be needed. Relates to: CCMRG-2037
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the
initialize_sentry_for_worker_processsignal handler that was callingsentry_sdk.init()again in each forked worker process.We believe this may be breaking CeleryIntegration's
build_tracerpatch - callinginit()a second time in child processes could interfere with the patches that were already applied in the parent process before fork.Investigation Findings
build_tracer patched: Falsein productionThe parent process's Sentry initialization (via
celeryd_initsignal inapp.py) should be inherited by forked children, so re-initialization may not be needed.Test Plan
Related
Relates to: CCMRG-2037
Note
Medium Risk
Changes Sentry initialization timing/behavior in worker processes, which could affect error/trace reporting if fork inheritance differs across environments; otherwise the diff is small and localized.
Overview
Stops re-initializing Sentry in each forked Celery worker process by removing the
worker_process_initSentry init signal handler and its related imports, relying on the parent-process initialization instead; Sentry flushing on worker shutdown remains.Also updates
apps/worker/Makefileto use the v2docker composeCLI for theshelltarget.Written by Cursor Bugbot for commit adfce9e. This will update automatically on new commits. Configure here.