Skip to content

Conversation

@dereuromark
Copy link
Owner

Summary

This PR adds generic queue job lifecycle events with an optional bridge for Sentry integration. This is an alternative to PRs #449 and #452, providing a middle-ground approach.

Generic Events

The plugin now dispatches standard lifecycle events:

  • Queue.Job.created - when a job is added to the queue
  • Queue.Job.started - when a worker begins processing a job
  • Queue.Job.completed - when a job finishes successfully
  • Queue.Job.failed - when a job fails (with exception data)

These events are useful for any monitoring, logging, or external integration.

Optional Sentry Integration

For lordsimal/cakephp-sentry integration, users can register the included CakeSentryEventBridge:

// In Application::bootstrap()
use Cake\Event\EventManager;
use Queue\Event\CakeSentryEventBridge;

EventManager::instance()->on(new CakeSentryEventBridge());

This bridges the generic events to CakeSentry.Queue.* events that the Sentry plugin listens to.

Key Benefits

Approach Description
Generic events Useful for any monitoring tool, not just Sentry
Optional bridge Users opt-in to Sentry integration by registering the bridge
No Sentry dependency Queue plugin has no dependency on Sentry SDK
Compatible with cakephp-sentry PR #43 The bridge dispatches events in the format expected by the Sentry plugin

Related Issues

Test plan

  • Test for Queue.Job.created event
  • Test for Queue.Job.started event
  • Test for Queue.Job.completed event
  • Test for Queue.Job.failed event
  • Tests for CakeSentryEventBridge listener
  • All 137 tests pass
  • Documentation updated

Add generic events for queue job lifecycle:
- Queue.Job.created: when job is added to queue
- Queue.Job.started: when job processing starts
- Queue.Job.completed: when job completes successfully
- Queue.Job.failed: when job fails

Add CakeSentryEventBridge listener that bridges these events to
CakeSentry.Queue.* events for lordsimal/cakephp-sentry integration.
Users can enable it with: EventManager::instance()->on(new CakeSentryEventBridge())
@codecov-commenter
Copy link

codecov-commenter commented Dec 28, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 97.14286% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.91%. Comparing base (e447805) to head (2487bfd).

Files with missing lines Patch % Lines
src/Event/CakeSentryEventBridge.php 96.00% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #453      +/-   ##
============================================
+ Coverage     73.28%   73.91%   +0.63%     
- Complexity      777      786       +9     
============================================
  Files            41       42       +1     
  Lines          2691     2760      +69     
============================================
+ Hits           1972     2040      +68     
- Misses          719      720       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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