Commit 7844c95a authored by Stan Hu's avatar Stan Hu

Ensure more of Sidekiq logs are in JSON

Because the Sidekiq log formatter was initialized after Sidekiq
initialized Redis, we would see some unstructured logs emitted at boot.
To fix this, move the log formatter up earlier in the Sidekiq init
process.

Closes https://gitlab.com/gitlab-org/gitlab/issues/208922
parent a89d86f0
...@@ -36,15 +36,6 @@ use_sidekiq_legacy_memory_killer = !use_sidekiq_daemon_memory_killer ...@@ -36,15 +36,6 @@ use_sidekiq_legacy_memory_killer = !use_sidekiq_daemon_memory_killer
use_request_store = ENV.fetch('SIDEKIQ_REQUEST_STORE', 1).to_i.nonzero? use_request_store = ENV.fetch('SIDEKIQ_REQUEST_STORE', 1).to_i.nonzero?
Sidekiq.configure_server do |config| Sidekiq.configure_server do |config|
config.redis = queues_config_hash
config.server_middleware(&Gitlab::SidekiqMiddleware.server_configurator({
metrics: Settings.monitoring.sidekiq_exporter,
arguments_logger: ENV['SIDEKIQ_LOG_ARGUMENTS'] && !enable_json_logs,
memory_killer: enable_sidekiq_memory_killer && use_sidekiq_legacy_memory_killer,
request_store: use_request_store
}))
if enable_json_logs if enable_json_logs
Sidekiq.logger.formatter = Gitlab::SidekiqLogging::JSONFormatter.new Sidekiq.logger.formatter = Gitlab::SidekiqLogging::JSONFormatter.new
config.options[:job_logger] = Gitlab::SidekiqLogging::StructuredLogger config.options[:job_logger] = Gitlab::SidekiqLogging::StructuredLogger
...@@ -54,6 +45,15 @@ Sidekiq.configure_server do |config| ...@@ -54,6 +45,15 @@ Sidekiq.configure_server do |config|
config.error_handlers << Gitlab::SidekiqLogging::ExceptionHandler.new config.error_handlers << Gitlab::SidekiqLogging::ExceptionHandler.new
end end
config.redis = queues_config_hash
config.server_middleware(&Gitlab::SidekiqMiddleware.server_configurator({
metrics: Settings.monitoring.sidekiq_exporter,
arguments_logger: ENV['SIDEKIQ_LOG_ARGUMENTS'] && !enable_json_logs,
memory_killer: enable_sidekiq_memory_killer && use_sidekiq_legacy_memory_killer,
request_store: use_request_store
}))
config.client_middleware(&Gitlab::SidekiqMiddleware.client_configurator) config.client_middleware(&Gitlab::SidekiqMiddleware.client_configurator)
config.on :startup do config.on :startup 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