DEV: Add job_id to sidkiq log

This makes it easier to correlate 'pending' logs from the same job
This commit is contained in:
David Taylor 2019-03-08 09:16:13 +00:00
parent b101065bad
commit 9db05a895a
1 changed files with 3 additions and 2 deletions

View File

@ -17,13 +17,14 @@ module Jobs
class Base
class JobInstrumenter
def initialize(job_class:, opts:, db:)
def initialize(job_class:, opts:, db:, jid:)
return unless enabled?
@data = {}
@data["hostname"] = `hostname`.strip # Hostname
@data["pid"] = Process.pid # Pid
@data["database"] = db # DB name - multisite db name it ran on
@data["job_id"] = jid # Job unique ID
@data["job_name"] = job_class.name # Job Name - eg: Jobs::AboutStats
@data["job_type"] = job_class.try(:scheduled?) ? "scheduled" : "regular" # Job Type - either s for scheduled or r for regular
@data["opts"] = opts.to_json # Params - json encoded params for the job
@ -185,7 +186,7 @@ module Jobs
exception = {}
RailsMultisite::ConnectionManagement.with_connection(db) do
job_instrumenter = JobInstrumenter.new(job_class: self.class, opts: opts, db: db)
job_instrumenter = JobInstrumenter.new(job_class: self.class, opts: opts, db: db, jid: jid)
begin
I18n.locale = SiteSetting.default_locale || "en"
I18n.ensure_all_loaded!