Commit d2146775 authored by nmilojevic1's avatar nmilojevic1

Fix Structured Logger

- Insert SidekiqServerMiddelware after Instrumentation Logger
parent 5ff51c71
......@@ -13,7 +13,7 @@ module EE
super.call(chain)
if load_balancing_enabled?
chain.insert_after(::Labkit::Middleware::Sidekiq::Server,
chain.insert_after(::Gitlab::SidekiqMiddleware::InstrumentationLogger,
::Gitlab::Database::LoadBalancing::SidekiqServerMiddleware)
end
end
......
......@@ -62,8 +62,8 @@ RSpec.describe Gitlab::SidekiqMiddleware do
::Gitlab::SidekiqMiddleware::ExtraDoneLogMetadata,
::Gitlab::SidekiqMiddleware::BatchLoader,
::Labkit::Middleware::Sidekiq::Server,
::Gitlab::Database::LoadBalancing::SidekiqServerMiddleware,
::Gitlab::SidekiqMiddleware::InstrumentationLogger,
::Gitlab::Database::LoadBalancing::SidekiqServerMiddleware,
::Gitlab::SidekiqMiddleware::AdminMode::Server,
::Gitlab::SidekiqVersioning::Middleware,
::Gitlab::SidekiqStatus::ServerMiddleware,
......
......@@ -39,7 +39,7 @@ module Gitlab
private
def add_instrumentation_keys!(job, output_payload)
output_payload.merge!(job[:instrumentation].stringify_keys)
output_payload.merge!(job[:instrumentation].stringify_keys) if job[:instrumentation]
end
def add_logging_extras!(job, output_payload)
......
......@@ -293,6 +293,16 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
end
end
end
context 'when instrumentation data is not loaded' do
before do
allow(logger).to receive(:info)
end
it 'does not raise exception' do
expect { subject.call(job.dup, 'test_queue') {} }.not_to raise_error
end
end
end
describe '#add_time_keys!' 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