Module: Logsy::JobHooks
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/logsy/job_hooks.rb
Overview
Include into your ApplicationJob (or specific jobs) to emit a single “wide event” log line when the job finishes — carrying the job class, queue, ActiveJob id, attempt count, duration_ms, status/error, and every Logsy tag set during the run (job_id/jid, propagated request_id, and anything the job wrote via ‘Logsy = value`, e.g. an RRN).
This is the background-job counterpart of Logsy::ControllerHooks. Per-job context capture (job_id, job_class, propagated tags) lives in Logsy::SidekiqMiddleware::Server — not here — so even ActiveJob’s own “Performing …” line is already tagged before this hook runs.
Usage:
class ApplicationJob < ActiveJob::Base
include Logsy::JobHooks
end
Override ‘logsy_job_summary_extras` to add custom fields to the event:
def logsy_job_summary_extras
{ tenant: account_id }
end
Job arguments are intentionally omitted — ActiveJob already logs them once at enqueue time (“Enqueued … with arguments: …”), correlatable by active_job_id, so repeating them here would only duplicate (and risk leaking) payload data.