Module: Gitlab::SidekiqLogging::LogsJobs

Included in:
DeduplicationLogger, StructuredLogger
Defined in:
lib/gitlab/sidekiq_logging/logs_jobs.rb

Instance Method Summary collapse

Instance Method Details

#base_message(payload) ⇒ Object


6
7
8
# File 'lib/gitlab/sidekiq_logging/logs_jobs.rb', line 6

def base_message(payload)
  "#{payload['class']} JID-#{payload['jid']}"
end

#parse_job(job) ⇒ Object

NOTE: Arguments are truncated/stringified in sidekiq_logging/json_formatter.rb


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/sidekiq_logging/logs_jobs.rb', line 11

def parse_job(job)
  # Error information from the previous try is in the payload for
  # displaying in the Sidekiq UI, but is very confusing in logs!
  job = job.except('error_backtrace', 'error_class', 'error_message')
  job['class'] = job.delete('wrapped') if job['wrapped'].present?

  job['job_size_bytes'] = Sidekiq.dump_json(job['args']).bytesize
  job['args'] = ['[COMPRESSED]'] if ::Gitlab::SidekiqMiddleware::SizeLimiter::Compressor.compressed?(job)

  # Add process id params
  job['pid'] = ::Process.pid

  job.delete('args') unless SidekiqLogArguments.enabled?

  job
end