Commit 8bc7ea0d authored by Quang-Minh Nguyen's avatar Quang-Minh Nguyen

Unwrap ActiveJob wrapper in Sidekiq logs

Issue https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/435
parent df83223b
......@@ -9,6 +9,9 @@ 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')
......
......@@ -89,6 +89,21 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
end
end
it 'logs real job wrapped by active job worker' do
wrapped_job = job.merge(
"class" => "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper",
"wrapped" => "TestWorker"
)
Timecop.freeze(timestamp) do
expect(logger).to receive(:info).with(start_payload).ordered
expect(logger).to receive(:info).with(end_payload).ordered
expect(subject).to receive(:log_job_start).and_call_original
expect(subject).to receive(:log_job_done).and_call_original
subject.call(wrapped_job, 'test_queue') {}
end
end
it 'logs an exception in job' do
Timecop.freeze(timestamp) do
expect(logger).to receive(:info).with(start_payload)
......
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