Skip to content

feat(ruby): add job extensions and shared instrumentation - #3129

Merged
solnic merged 4 commits into
masterfrom
feat/3117-public-backend-extension-registry-for-background-job-integrations
Nov 11, 2026
Merged

solnic merged 4 commits into
masterfrom
feat/3117-public-backend-extension-registry-for-background-job-integrations

Conversation

@solnic

@solnic solnic commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

This introduces a public API for queue systems (ActiveJob, Sidekiq, GoodJob, SolidQueue etc.) to integrate with Sentry by subclassing Sentry::JobExtensions::Extension:

module MyBackend
  class SentryExtension < Sentry::JobExtensions::Extension
    def initialize
      super(name: :my_backend, integration: MyBackend::SentryIntegration, origin: "auto.queue.my_backend")
    end

    def scope_data(job:, **)
      { tags: { queue: job.queue_name } }
    end

    def messaging_data(job:, **)
      { system: name, message_id: job.job_id, destination: job.queue_name }
    end
  end
end

Integrations call the extension around enqueueing and performing a job:

extension.instrument_enqueue(job: job) { enqueue }

transaction = extension.start_job(scope: scope, job: job)
# perform the job
extension.finish_job(transaction: transaction, status: 200)

extension.capture_exception(job: job, exception: error) if extension.report_exception?(job: job, exception: error)

These record the queue.publish span and the queue.process transaction, and capture the job's exceptions. The data they record comes from hooks the subclass overrides, such as scope_data, error_data, messaging_data, will_retry?, report_exception?, record_publish_span?, extract_trace_headers, inject_trace_headers, transaction_name and span_origin.

Hooks take keyword arguments and accept keywords they don't read, so integrations can pass extra context. A failing hook is logged and the job runs without its data.


Closes #3117
Closes #3123

@solnic
solnic added this pull request to stack #3135 October 13, 2026 13:17
@solnic
solnic marked this pull request as draft October 13, 2026 13:25
@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch from 120f7a3 to 24621bb Compare October 14, 2026 09:17
@solnic
solnic marked this pull request as ready for review October 14, 2026 09:49
@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch 3 times, most recently from 18edb4c to 605bebc Compare October 14, 2026 11:42
@solnic
solnic removed this pull request from stack #3135 October 14, 2026 11:44
@solnic solnic changed the title feat(ruby): add public backend-extension registry feat(ruby): add job extensions and shared instrumentation Oct 14, 2026
@solnic
solnic added this pull request to stack #3137 October 14, 2026 11:44
cursor[bot]

This comment was marked as resolved.

@solnic
solnic marked this pull request as draft October 15, 2026 08:25
@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch 3 times, most recently from 2cddb72 to 3fa983c Compare October 15, 2026 11:00
@solnic
solnic marked this pull request as ready for review October 15, 2026 12:19
cursor[bot]

This comment was marked as resolved.

@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch 2 times, most recently from 27970e7 to e3ade51 Compare October 15, 2026 12:51
cursor[bot]

This comment was marked as resolved.

@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch from 5eaa1a5 to 77e02b1 Compare October 15, 2026 13:37
@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch 3 times, most recently from 35fb71a to 0df0bb8 Compare October 23, 2026 11:49
@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch from 0df0bb8 to f5eee4a Compare November 2, 2026 15:56
@solnic
solnic marked this pull request as draft November 2, 2026 15:57
@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch 3 times, most recently from a213bfd to 7e7b39b Compare November 3, 2026 12:01
@solnic
solnic marked this pull request as ready for review November 3, 2026 14:29

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch 2 times, most recently from 8c54390 to f9f7593 Compare November 4, 2026 10:25

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch 2 times, most recently from bf6aff9 to 6a05c59 Compare November 4, 2026 15:02

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch from 6a05c59 to 5b2d854 Compare November 5, 2026 09:50
@sl0thentr0py

Copy link
Copy Markdown
Member

approving to unblock, feel free to address comments or not

@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch 2 times, most recently from cf33189 to f5e2c72 Compare November 9, 2026 09:54

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f5e2c72. Configure here.

@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch from f5e2c72 to a6b58ce Compare November 10, 2026 13:45
Document and name the caller > scope > extension merge in
merged_error_data, and skip capture when the SDK is not initialized.
hook_hash only coerces the top-level value scope_data returns, and
apply_scope_data ran outside safely. A tags, extra, user or context value
that is not a Hash made the Scope setters raise ArgumentError from
start_job, so the job never ran. Apply the scope data through safely,
as the other hooks are, so the failure is logged and the job runs.
@solnic
solnic force-pushed the feat/3117-public-backend-extension-registry-for-background-job-integrations branch from 0e122f4 to 2b10566 Compare November 10, 2026 19:27
@solnic
solnic merged commit 6818450 into master Nov 11, 2026
287 of 290 checks passed
@solnic
solnic deleted the feat/3117-public-backend-extension-registry-for-background-job-integrations branch November 11, 2026 09:02
dingsdax added a commit to getsentry/sentry-changelog that referenced this pull request Nov 18, 2026
Adds a changelog post for [sentry-ruby
7.3.0](https://github.com/getsentry/sentry-ruby/releases/tag/7.3.0), so
Ruby users hear about the release's new features in the changelog and in
Sentry's "What's New" panel (scoped to Ruby, Rails, and Rack orgs) and
not only in the GitHub release notes.

The post is framed around background work that fails quietly, and each
section leads with the problem it solves:

- **Know when a GoodJob cron job fails or never runs**:
`config.enabled_patches << :good_job_cron` puts every GoodJob cron entry
under Crons monitoring (getsentry/sentry-ruby#3200)
- **See which feature flags were on when an error happened**:
`Sentry.add_feature_flag` attaches flag evaluations to errors and spans
(getsentry/sentry-ruby#3108)
- **Spot jobs piling up in the queue**: ActiveJob, Sidekiq, and Resque
jobs report queue wait time and payload size for the Queues dashboard
(getsentry/sentry-ruby#3133)

It closes with `Sentry.logger` block support
(getsentry/sentry-ruby#3178), then links the full release notes. The new
job extensions API (getsentry/sentry-ruby#3129) is left out because it
only matters to people who maintain job backends. Nothing breaks.

Open decisions:
- The entry is `published: false`, so merging only creates it. To go
live, set `published: true` before merge or publish it from the admin
UI.
- `author` is left unset because I couldn't confirm which email belongs
to an existing changelog user. Add one if you want the post attributed.

<!-- junior-request-attribution:start -->
via @dingsdax.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3Ab5614f77a180622dc700158a -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/local%3Aweb%3Ab5614f77a180622dc700158a)
[[Sentry]](https://sentry.sentry.io/explore/conversations/local%3Aweb%3Ab5614f77a180622dc700158a/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: johdax <114897+dingsdax@users.noreply.github.com>
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.

Shared queue instrumentation helpers Public backend-extension registry for background job integrations

2 participants