-
Notifications
You must be signed in to change notification settings - Fork 11
fix(worker): Remove Sentry re-initialization in forked workers #680
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
base: main
Are you sure you want to change the base?
fix(worker): Remove Sentry re-initialization in forked workers #680
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! |
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
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.