Skip to content

Conversation

@drazisil-codecov
Copy link
Contributor

@drazisil-codecov drazisil-codecov commented Jan 30, 2026

Summary

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.

Test Plan

  • Deploy to staging and verify worker transactions appear in Sentry
  • Deploy to production and monitor for worker transactions
  • Verify errors are still captured correctly

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_init Sentry init signal handler and its related imports, relying on the parent-process initialization instead; Sentry flushing on worker shutdown remains.

Also updates apps/worker/Makefile to use the v2 docker compose CLI for the shell target.

Written by Cursor Bugbot for commit adfce9e. This will update automatically on new commits. Configure here.

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
@linear
Copy link

linear bot commented Jan 30, 2026

@sentry
Copy link

sentry bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.43%. Comparing base (2918025) to head (1ed767c).
✅ All tests successful. No failed tests found.

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           
Flag Coverage Δ
workerintegration 58.59% <ø> (-0.01%) ⬇️
workerunit 90.34% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@drazisil-codecov drazisil-codecov added this pull request to the merge queue 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
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 2, 2026
@drazisil-codecov drazisil-codecov added this pull request to the merge queue Feb 2, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 2, 2026
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.

3 participants