diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-12-05 23:54:40 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-12-06 22:46:14 +0300 |
commit | 39c1731a53d1014eab7c876d70632b1abf738712 (patch) | |
tree | 5d51a48a32a92fdedf7b907a32caa172d1c0d923 /config/initializers | |
parent | cfe484795d4ddb8c7b3247802547e3da74c64cf2 (diff) |
Log and pass correlation-id between Unicorn, Sidekiq and Gitaly
The Correlation ID is taken or generated from received X-Request-ID.
Then it is being passed to all executed services (sidekiq workers
or gitaly calls).
The Correlation ID is logged in all structured logs as `correlation_id`.
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/correlation_id.rb | 3 | ||||
-rw-r--r-- | config/initializers/lograge.rb | 1 | ||||
-rw-r--r-- | config/initializers/sentry.rb | 2 | ||||
-rw-r--r-- | config/initializers/sidekiq.rb | 3 |
4 files changed, 8 insertions, 1 deletions
diff --git a/config/initializers/correlation_id.rb b/config/initializers/correlation_id.rb new file mode 100644 index 00000000000..2a7c138dc40 --- /dev/null +++ b/config/initializers/correlation_id.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +Rails.application.config.middleware.use(Gitlab::Middleware::CorrelationId) diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index 840404e0ec0..c897bc30e76 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -29,6 +29,7 @@ unless Sidekiq.server? gitaly_calls = Gitlab::GitalyClient.get_request_count payload[:gitaly_calls] = gitaly_calls if gitaly_calls > 0 payload[:response] = event.payload[:response] if event.payload[:response] + payload[Gitlab::CorrelationId::LOG_KEY] = Gitlab::CorrelationId.current_id payload end diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 17d09293205..2a6c5148f71 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -24,4 +24,4 @@ def configure_sentry end end -configure_sentry if Rails.env.production? +configure_sentry if Rails.env.production? || Rails.env.development? diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 4210be2c701..fc9285e1fee 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -21,6 +21,7 @@ Sidekiq.configure_server do |config| chain.add Gitlab::SidekiqMiddleware::Shutdown chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware unless ENV['SIDEKIQ_REQUEST_STORE'] == '0' chain.add Gitlab::SidekiqMiddleware::BatchLoader + chain.add Gitlab::SidekiqMiddleware::CorrelationLogger chain.add Gitlab::SidekiqStatus::ServerMiddleware end @@ -31,6 +32,7 @@ Sidekiq.configure_server do |config| config.client_middleware do |chain| chain.add Gitlab::SidekiqStatus::ClientMiddleware + chain.add Gitlab::SidekiqMiddleware::CorrelationInjector end config.on :startup do @@ -75,6 +77,7 @@ Sidekiq.configure_client do |config| config.redis = queues_config_hash config.client_middleware do |chain| + chain.add Gitlab::SidekiqMiddleware::CorrelationInjector chain.add Gitlab::SidekiqStatus::ClientMiddleware end end |