Skip to content

feat(rails): run ActiveJob reporting through job extensions - #3130

Merged
solnic merged 4 commits into
chore/3121-queues-module-conformance-improvementsfrom
chore/3119-switch-activejob-integration-to-the-backend-extension-registry
Nov 11, 2026
Merged

solnic merged 4 commits into
chore/3121-queues-module-conformance-improvementsfrom
chore/3119-switch-activejob-integration-to-the-backend-extension-registry

Conversation

@solnic

@solnic solnic commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

The ActiveJob integration now runs on the job extension API from #3129. Backends subclass Sentry::Rails::ActiveJobExtension and register it for their queue adapter:

class MyBackendExtension < Sentry::Rails::ActiveJobExtension
  def initialize
    super(name: "my_backend")
  end

  def messaging_data(job:, **)
    super.merge(system: "my_backend")
  end
end

Sentry::Rails.register_active_job_extension(:my_backend, MyBackendExtension.new)

Jobs on an adapter without a registered extension use ActiveJobExtension itself. Every job keeps the active_job context, the queue tag and ActiveJob's error data. An extension's error_data is added on top of that.

Other changes:

  • Sentry::Rails.active_job_owns_adapter?(adapter) tells backend gems whether sentry-rails reports jobs for a queue adapter.
  • A backend that records its own queue.publish span returns false from record_publish_span?.
  • Consumer transactions report messaging.message.body.size when sampled.

Closes #3119

@solnic
solnic added this pull request to stack #3135 October 13, 2026 13:17
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from 75aefea to 243c2a0 Compare October 13, 2026 13:23
@solnic
solnic marked this pull request as draft October 13, 2026 13: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 chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch 3 times, most recently from e9dd3a1 to bb053a7 Compare October 14, 2026 09:17
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from bb053a7 to 2fdd2a7 Compare October 14, 2026 10:34
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from 2fdd2a7 to 0921325 Compare October 14, 2026 10:56
@solnic
solnic marked this pull request as ready for review October 14, 2026 11:14

@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 chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from 0921325 to 0411b4d Compare October 14, 2026 11:42
@solnic
solnic removed this pull request from stack #3135 October 14, 2026 11:44
@solnic
solnic changed the base branch from feat/3117-public-backend-extension-registry-for-background-job-integrations to chore/3121-queues-module-conformance-improvements October 14, 2026 11:44
@solnic
solnic added this pull request to stack #3137 October 14, 2026 11:44
@solnic
solnic marked this pull request as draft October 15, 2026 08:25
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from 0411b4d to ff06d8b Compare October 15, 2026 08:27
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from ff06d8b to db6e8f6 Compare October 15, 2026 08:32
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch 3 times, most recently from c50b6dd to f9b1dda Compare October 15, 2026 10:20
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from f9b1dda to 35d5037 Compare October 15, 2026 10:44
@solnic
solnic marked this pull request as draft November 2, 2026 15:58
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch 2 times, most recently from c2a7302 to c675cb8 Compare November 2, 2026 16:45
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from c675cb8 to fe10802 Compare November 3, 2026 09:19
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch 2 times, most recently from 7731c01 to 8429ff3 Compare November 3, 2026 12:01
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from 9ede876 to 65c56c8 Compare November 3, 2026 14:46
@solnic
solnic marked this pull request as ready for review November 3, 2026 14:54
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from 65c56c8 to 7678e20 Compare November 4, 2026 10:23
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from 7678e20 to 4878f63 Compare November 4, 2026 10:26
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from 4878f63 to c5e0f5f Compare November 4, 2026 10:52
@solnic
solnic force-pushed the chore/3119-switch-activejob-integration-to-the-backend-extension-registry branch from c5e0f5f to c45c2e8 Compare November 4, 2026 11:40

@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.

@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.

@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.

A job extension whose inject_trace_headers returned nil or a non-Hash
replaced the serialized payload, so the _sentry merge raised and the
rescue handed that value to the queue adapter, failing the enqueue. Use
the hook's result only when it is a Hash and fall back to the original
payload on any failure.
messaging_data called publish_messaging_data, the reverse of the base extension, so a subclass
whose publish_messaging_data built on messaging_data recursed until the stack overflowed. Both
hooks now build on a private helper and report the same attributes as before.

@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 2 potential issues.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit f9f85c7. Configure here.


def self.prepended(base)
base.attr_accessor :_sentry
base.attr_reader :_sentry_job_data

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Public job helper exposes SDK internals

Low Severity

Prepending ActiveJobExtensions now adds a public _sentry_job_data reader on every ActiveJob class. That helper becomes part of the app's job API even though it only exists so the extension can read the serialized payload. SDK state on a job ancestor needs to stay private rather than a public accessor.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by learned rule: Prepend patches must keep original visibility

Reviewed by Cursor Bugbot for commit f9f85c7. Configure here.

end

begin
Sentry.with_child_span(op: "queue.publish", description: job.class.name) do |span|

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unused reporter capture_exception left behind

Low Severity

SentryReporter.capture_exception now only forwards to the job extension and has no remaining callers. Perform and retry paths both invoke extension.capture_exception directly, so this method is dead code left from the refactor.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f9f85c7. Configure here.

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.

Switch ActiveJob integration to the backend-extension registry

2 participants