Commit b17c388e authored by Quang-Minh Nguyen's avatar Quang-Minh Nguyen

Does not modify job in the structured job

parent 5faa90ec
......@@ -9,12 +9,10 @@ module Gitlab
# NOTE: Arguments are truncated/stringified in sidekiq_logging/json_formatter.rb
def parse_job(job)
if job['wrapped'].present?
job['class'] = job.delete('wrapped')
end
# 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?
# Add process id params
job['pid'] = ::Process.pid
......
......@@ -188,6 +188,24 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
end
end
end
it 'does not modify the wrapped job' do
Timecop.freeze(timestamp) do
wrapped_job = job.merge(
"class" => "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper",
"wrapped" => "TestWorker"
)
job_copy = wrapped_job.deep_dup
allow(logger).to receive(:info)
allow(subject).to receive(:log_job_start).and_call_original
allow(subject).to receive(:log_job_done).and_call_original
subject.call(wrapped_job, 'test_queue') do
expect(wrapped_job).to eq(job_copy)
end
end
end
end
context 'with SIDEKIQ_LOG_ARGUMENTS disabled' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment