diff options
author | Stan Hu <stanhu@gmail.com> | 2018-04-01 00:46:52 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-04-04 05:04:00 -0700 |
commit | 6415ac9e994640474eaa5b0fee3914934d85b35b (patch) | |
tree | 2640006fbc3745039799bb76bf8a654f5ce592c0 /config/initializers/sidekiq.rb | |
parent | eaed588bf228c833cb666a61bc7d25cf21d5f94b (diff) | |
download | gitlab-ce-6415ac9e994640474eaa5b0fee3914934d85b35b.tar.gz |
Add support for Sidekiq JSON logging
Closes #20060
Diffstat (limited to 'config/initializers/sidekiq.rb')
-rw-r--r-- | config/initializers/sidekiq.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 161fb185c9b..f6803eb0b5a 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -5,16 +5,23 @@ queues_config_hash[:namespace] = Gitlab::Redis::Queues::SIDEKIQ_NAMESPACE # Default is to retry 25 times with exponential backoff. That's too much. Sidekiq.default_worker_options = { retry: 3 } +enable_json_logs = Gitlab.config.sidekiq.log_format == 'json' + Sidekiq.configure_server do |config| config.redis = queues_config_hash config.server_middleware do |chain| - chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV['SIDEKIQ_LOG_ARGUMENTS'] + chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV['SIDEKIQ_LOG_ARGUMENTS'] && !enable_json_logs chain.add Gitlab::SidekiqMiddleware::Shutdown chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware unless ENV['SIDEKIQ_REQUEST_STORE'] == '0' chain.add Gitlab::SidekiqStatus::ServerMiddleware end + if enable_json_logs + Sidekiq.logger.formatter = Gitlab::SidekiqLogging::JSONFormatter.new + config.options[:job_logger] = Gitlab::SidekiqLogging::StructuredLogger + end + config.client_middleware do |chain| chain.add Gitlab::SidekiqStatus::ClientMiddleware end |