Class: ActiveJob::StructuredEventSubscriber
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
ActiveSupport::StructuredEventSubscriber
|
Defined in: | activejob/lib/active_job/structured_event_subscriber.rb |
Constant Summary
Class Attribute Summary
::ActiveSupport::StructuredEventSubscriber
- Inherited
::ActiveSupport::Subscriber
- Inherited
Class Method Summary
::ActiveSupport::StructuredEventSubscriber
- Inherited
::ActiveSupport::Subscriber
- Inherited
.attach_to | Attach the subscriber to a namespace. |
.detach_from | Detach the subscriber from a namespace. |
.method_added | Adds event subscribers for all new methods added to the class. |
.new, .subscribers, .add_event_subscriber, .fetch_public_methods, .find_attached_subscriber, .invalid_event?, .pattern_subscribed?, .prepare_pattern, .remove_event_subscriber |
Instance Attribute Summary
::ActiveSupport::StructuredEventSubscriber
- Inherited
::ActiveSupport::Subscriber
- Inherited
Instance Method Summary
- #discard(event)
- #enqueue(event)
- #enqueue_all(event)
- #enqueue_at(event)
- #enqueue_retry(event)
- #interrupt(event)
- #perform(event)
- #perform_start(event)
- #resume(event)
- #retry_stopped(event)
- #step(event)
- #step_skipped(event)
- #step_started(event)
::ActiveSupport::StructuredEventSubscriber
- Inherited
#call, | |
#emit_debug_event | Like |
#emit_event | Emit a structured event via Rails.event.notify. |
#silenced?, #handle_event_error |
::ActiveSupport::Subscriber
- Inherited
Constructor Details
This class inherits a constructor from ActiveSupport::StructuredEventSubscriber
Instance Method Details
#discard(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 128
def discard(event) job = event.payload[:job] exception = event.payload[:error] emit_event("active_job.discarded", job_class: job.class.name, job_id: job.job_id, exception_class: exception.class.name, exception_message: exception. ) end
#enqueue(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 7
def enqueue(event) job = event.payload[:job] exception = event.payload[:exception_object] || job.enqueue_error payload = { job_class: job.class.name, job_id: job.job_id, queue: job.queue_name, aborted: event.payload[:aborted], } if exception payload[:exception_class] = exception.class.name payload[: ] = exception. end if job.class.log_arguments? payload[:arguments] = job.arguments end emit_event("active_job.enqueued", payload) end
#enqueue_all(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 52
def enqueue_all(event) jobs = event.payload[:jobs] adapter = event.payload[:adapter] enqueued_count = event.payload[:enqueued_count].to_i failed_count = jobs.size - enqueued_count emit_event("active_job.bulk_enqueued", adapter: ActiveJob.adapter_name(adapter), total_jobs: jobs.size, enqueued_count: enqueued_count, failed_count: failed_count, job_classes: jobs.map { |job| job.class.name }.tally ) end
#enqueue_at(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 29
def enqueue_at(event) job = event.payload[:job] exception = event.payload[:exception_object] || job.enqueue_error payload = { job_class: job.class.name, job_id: job.job_id, queue: job.queue_name, scheduled_at: job.scheduled_at, aborted: event.payload[:aborted], } if exception payload[:exception_class] = exception.class.name payload[: ] = exception. end if job.class.log_arguments? payload[:arguments] = job.arguments end emit_event("active_job.enqueued", payload) end
#enqueue_retry(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 100
def enqueue_retry(event) job = event.payload[:job] exception = event.payload[:error] wait = event.payload[:wait] emit_event("active_job.retry_scheduled", job_class: job.class.name, job_id: job.job_id, executions: job.executions, wait_seconds: wait.to_i, exception_class: exception&.class&.name, exception_message: exception&. ) end
#interrupt(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 140
def interrupt(event) job = event.payload[:job] description = event.payload[:description] reason = event.payload[:reason] emit_event("active_job.interrupt", job_class: job.class.name, job_id: job.job_id, description: description, reason: reason, ) end
#perform(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 81
def perform(event) job = event.payload[:job] exception = event.payload[:exception_object] payload = { job_class: job.class.name, job_id: job.job_id, queue: job.queue_name, aborted: event.payload[:aborted], duration: event.duration.round(2), } if exception payload[:exception_class] = exception.class.name payload[: ] = exception. end emit_event("active_job.completed", payload) end
#perform_start(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 67
def perform_start(event) job = event.payload[:job] payload = { job_class: job.class.name, job_id: job.job_id, queue: job.queue_name, enqueued_at: job.enqueued_at&.utc&.iso8601(9), } if job.class.log_arguments? payload[:arguments] = job.arguments end emit_event("active_job.started", payload) end
#resume(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 153
def resume(event) job = event.payload[:job] description = event.payload[:description] emit_event("active_job.resume", job_class: job.class.name, job_id: job.job_id, description: description, ) end
#retry_stopped(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 115
def retry_stopped(event) job = event.payload[:job] exception = event.payload[:error] emit_event("active_job.retry_stopped", job_class: job.class.name, job_id: job.job_id, executions: job.executions, exception_class: exception.class.name, exception_message: exception. ) end
#step(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 188
def step(event) job = event.payload[:job] step = event.payload[:step] exception = event.payload[:exception_object] payload = { job_class: job.class.name, job_id: job.job_id, step: step.name, cursor: step.cursor, interrupted: event.payload[:interrupted], duration: event.duration.round(2), } if exception payload[:exception_class] = exception.class.name payload[: ] = exception. end emit_event("active_job.step", payload) end
#step_skipped(event)
[ GitHub ]#step_started(event)
[ GitHub ]# File 'activejob/lib/active_job/structured_event_subscriber.rb', line 175
def step_started(event) job = event.payload[:job] step = event.payload[:step] emit_event("active_job.step_started", job_class: job.class.name, job_id: job.job_id, step: step.name, cursor: step.cursor, resumed: step.resumed?, ) end