summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-12-06 21:46:31 +0100
committerKamil Trzciński <ayufan@ayufan.eu>2018-12-06 21:46:31 +0100
commitebb5d9f4db3c2d5818f5efda1b09fcd1be7285e8 (patch)
tree5d51a48a32a92fdedf7b907a32caa172d1c0d923
parent3560b11922fd180eea5cafd0e763e0e601c5c4ee (diff)
downloadgitlab-ce-ebb5d9f4db3c2d5818f5efda1b09fcd1be7285e8.tar.gz
Revert "Prefer to use correlation-id in logs"
This reverts commit 3560b11922fd180eea5cafd0e763e0e601c5c4ee.
-rw-r--r--lib/gitlab/correlation_id.rb2
-rw-r--r--lib/gitlab/gitaly_client.rb2
-rw-r--r--lib/gitlab/sentry.rb2
-rw-r--r--spec/controllers/application_controller_spec.rb2
-rw-r--r--spec/initializers/lograge_spec.rb6
-rw-r--r--spec/lib/gitlab/json_logger_spec.rb4
-rw-r--r--spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb2
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb2
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb2
9 files changed, 12 insertions, 12 deletions
diff --git a/lib/gitlab/correlation_id.rb b/lib/gitlab/correlation_id.rb
index 8431d88f8eb..0f9bde4390e 100644
--- a/lib/gitlab/correlation_id.rb
+++ b/lib/gitlab/correlation_id.rb
@@ -2,7 +2,7 @@
module Gitlab
module CorrelationId
- LOG_KEY = 'correlation-id'.freeze
+ LOG_KEY = 'correlation_id'.freeze
class << self
def use_id(correlation_id, &blk)
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index 158f7d47bd2..255601382b1 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -193,7 +193,7 @@ module Gitlab
feature = feature_stack && feature_stack[0]
metadata['call_site'] = feature.to_s if feature
metadata['gitaly-servers'] = address_metadata(remote_storage) if remote_storage
- metadata[Gitlab::CorrelationId::LOG_KEY] = Gitlab::CorrelationId.current_id if Gitlab::CorrelationId.current_id
+ metadata['correlation_id'] = Gitlab::CorrelationId.current_id if Gitlab::CorrelationId.current_id
metadata.merge!(server_feature_flags)
diff --git a/lib/gitlab/sentry.rb b/lib/gitlab/sentry.rb
index 3d82934f268..46d01964eac 100644
--- a/lib/gitlab/sentry.rb
+++ b/lib/gitlab/sentry.rb
@@ -45,7 +45,7 @@ module Gitlab
context # Make sure we've set everything we know in the context
tags = {
- correlation_id: Gitlab::CorrelationId.current_id
+ Gitlab::CorrelationId::LOG_KEY.to_sym => Gitlab::CorrelationId.current_id
}
Raven.capture_exception(exception, tags: tags, extra: extra)
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 20217e2b67f..c2bd7fd9808 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -465,7 +465,7 @@ describe ApplicationController do
get :index
end
- expect(controller.last_payload).to include('correlation-id' => 'new-id')
+ expect(controller.last_payload).to include('correlation_id' => 'new-id')
end
context '422 errors' do
diff --git a/spec/initializers/lograge_spec.rb b/spec/initializers/lograge_spec.rb
index bf5dde7fe66..af54a777373 100644
--- a/spec/initializers/lograge_spec.rb
+++ b/spec/initializers/lograge_spec.rb
@@ -11,7 +11,7 @@ describe 'lograge', type: :request do
it 'logs to api_json log' do
# we assert receiving parameters by grape logger
expect_any_instance_of(Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp).to receive(:call)
- .with(anything, anything, anything, a_hash_including("correlation-id" => "new-correlation-id"))
+ .with(anything, anything, anything, a_hash_including("correlation_id" => "new-correlation-id"))
.and_call_original
subject
@@ -24,12 +24,12 @@ describe 'lograge', type: :request do
it 'logs to production_json log' do
# formatter receives a hash with correlation id
expect(Lograge.formatter).to receive(:call)
- .with(a_hash_including("correlation-id" => "new-correlation-id"))
+ .with(a_hash_including("correlation_id" => "new-correlation-id"))
.and_call_original
# a log file receives a line with correlation id
expect(Lograge.logger).to receive(:send)
- .with(anything, include('"correlation-id":"new-correlation-id"'))
+ .with(anything, include('"correlation_id":"new-correlation-id"'))
.and_call_original
subject
diff --git a/spec/lib/gitlab/json_logger_spec.rb b/spec/lib/gitlab/json_logger_spec.rb
index 706601fe98f..cff7dd58c8c 100644
--- a/spec/lib/gitlab/json_logger_spec.rb
+++ b/spec/lib/gitlab/json_logger_spec.rb
@@ -18,7 +18,7 @@ describe Gitlab::JsonLogger do
expect(data['severity']).to eq('INFO')
expect(data['time']).to eq(now.utc.iso8601(3))
expect(data['message']).to eq('Hello world')
- expect(data['correlation-id']).to eq('new-correlation-id')
+ expect(data['correlation_id']).to eq('new-correlation-id')
end
it 'formats hashes' do
@@ -29,7 +29,7 @@ describe Gitlab::JsonLogger do
expect(data['time']).to eq(now.utc.iso8601(3))
expect(data['hello']).to eq(1)
expect(data['message']).to be_nil
- expect(data['correlation-id']).to eq('new-correlation-id')
+ expect(data['correlation_id']).to eq('new-correlation-id')
end
end
end
diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
index 7484593268c..f773f370ee2 100644
--- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
+++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
@@ -13,7 +13,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
"jid" => "da883554ee4fe414012f5f42",
"created_at" => timestamp.to_f,
"enqueued_at" => timestamp.to_f,
- "correlation-id" => 'cid'
+ "correlation_id" => 'cid'
}
end
let(:logger) { double() }
diff --git a/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb b/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb
index 291e0624e96..a138ad7c910 100644
--- a/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb
@@ -37,7 +37,7 @@ describe Gitlab::SidekiqMiddleware::CorrelationInjector do
expected_job_params = {
"class" => "TestWorker",
"args" => [1234],
- "correlation-id" => "new-correlation-id"
+ "correlation_id" => "new-correlation-id"
}
expect(Sidekiq::Queues.jobs_by_worker).to a_hash_including(
diff --git a/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb b/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb
index 35696286218..94ae4ffa184 100644
--- a/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb
@@ -30,6 +30,6 @@ describe Gitlab::SidekiqMiddleware::CorrelationLogger do
'queue' => 'test',
'class' => TestWorker,
'args' => [1234],
- 'correlation-id' => 'new-correlation-id')
+ 'correlation_id' => 'new-correlation-id')
end
end