Skip to content

Conversation

@dereuromark
Copy link
Owner

Summary

This PR adds events at key lifecycle points in queue job processing to enable integration with monitoring tools like Sentry:

  • Queue.Job.created: Fired when a job is added to the queue (producer side)
  • Queue.Job.started: Fired when a worker begins processing a job (consumer side)
  • Queue.Job.completed: Fired when a job finishes successfully
  • Queue.Job.failed: Fired on every job failure (not just when retries exhausted)

These events enable integration with Sentry's Insights - Queues feature and similar monitoring tools. The job entity included in each event provides all necessary data for tracing:

  • $job->id - Message identifier
  • $job->job_task - Queue/topic name
  • $job->data - Payload for calculating message size
  • $job->attempts - Retry count
  • $job->created, $job->notbefore, $job->fetched - For calculating receive latency

Related Issues

Test plan

  • Added tests for Queue.Job.created event in QueuedJobsTableTest
  • Added tests for Queue.Job.started event in ProcessorTest
  • Added tests for Queue.Job.completed event in ProcessorTest
  • Added tests for Queue.Job.failed event in ProcessorTest
  • All 130 tests pass
  • Documentation updated in docs/sections/misc.md

🤖 Generated with Claude Code

@dereuromark dereuromark force-pushed the feature/queue-monitoring-events branch from d28ff48 to 41c2d1f Compare November 23, 2025 11:23
Add events at key lifecycle points to enable integration with monitoring
tools like Sentry:

- Queue.Job.created: Fired when a job is added to the queue (producer)
- Queue.Job.started: Fired when a worker begins processing a job (consumer)
- Queue.Job.completed: Fired when a job finishes successfully
- Queue.Job.failed: Fired on every job failure (not just when exhausted)

Additionally, provide built-in Sentry integration that can be enabled via
`Queue.sentry` configuration. When enabled:
- Creates queue.publish spans for producer side
- Creates queue.process transactions for consumer side
- Propagates trace context via job data
- Includes all standard messaging attributes

Refs: LordSimal/cakephp-sentry#17

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@dereuromark dereuromark force-pushed the feature/queue-monitoring-events branch from 41c2d1f to 7927e42 Compare November 23, 2025 11:32
@dereuromark
Copy link
Owner Author

Thats quite a bit of code to support sentry here, but I guess worth it.

@LordSimal
Copy link
Contributor

Thinking about this again I'd say lets just stay with the pure event based system.
I do all the sentry specific things in my plugin and you just send an event with all the data I'd expect.

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