diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2019-09-03 07:43:46 +0300 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2019-09-03 07:43:46 +0300 |
commit | 594f56e1ef2ea2032728e3288cb9aee6146739fc (patch) | |
tree | 2693e6931c0d918ce2720b863d202bc690a5e22e | |
parent | 4e4fcf79c57f9c6f62b7a1cfbb6a83ee154f05fa (diff) | |
parent | 0234795825640022ccd43476e3c679d4e054a46f (diff) |
Merge branch 'an-use-labkit-correlation-id' into 'master'
Remove all references to Gitlab::CorrelationId
See merge request gitlab-org/gitlab-ce!32228
-rw-r--r-- | lib/gitlab/correlation_id.rb | 40 | ||||
-rw-r--r-- | lib/gitlab/tracing.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing_spec.rb | 2 |
3 files changed, 2 insertions, 42 deletions
diff --git a/lib/gitlab/correlation_id.rb b/lib/gitlab/correlation_id.rb deleted file mode 100644 index 0f9bde4390e..00000000000 --- a/lib/gitlab/correlation_id.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module CorrelationId - LOG_KEY = 'correlation_id'.freeze - - class << self - def use_id(correlation_id, &blk) - # always generate a id if null is passed - correlation_id ||= new_id - - ids.push(correlation_id || new_id) - - begin - yield(current_id) - ensure - ids.pop - end - end - - def current_id - ids.last - end - - def current_or_new_id - current_id || new_id - end - - private - - def ids - Thread.current[:correlation_id] ||= [] - end - - def new_id - SecureRandom.uuid - end - end - end -end diff --git a/lib/gitlab/tracing.rb b/lib/gitlab/tracing.rb index 29517591c51..7732d7c9d9c 100644 --- a/lib/gitlab/tracing.rb +++ b/lib/gitlab/tracing.rb @@ -30,7 +30,7 @@ module Gitlab # Avoid using `format` since it can throw TypeErrors # which we want to avoid on unsanitised env var input tracing_url_template.to_s - .gsub(/\{\{\s*correlation_id\s*\}\}/, Gitlab::CorrelationId.current_id.to_s) + .gsub(/\{\{\s*correlation_id\s*\}\}/, Labkit::Correlation::CorrelationId.current_id.to_s) .gsub(/\{\{\s*service\s*\}\}/, Gitlab.process_name) end end diff --git a/spec/lib/gitlab/tracing_spec.rb b/spec/lib/gitlab/tracing_spec.rb index db75ce2a998..e913bb600ec 100644 --- a/spec/lib/gitlab/tracing_spec.rb +++ b/spec/lib/gitlab/tracing_spec.rb @@ -59,7 +59,7 @@ describe Gitlab::Tracing do it 'returns the correct state for .tracing_url' do expect(described_class).to receive(:tracing_url_enabled?).and_return(tracing_url_enabled?) allow(described_class).to receive(:tracing_url_template).and_return(tracing_url_template) - allow(Gitlab::CorrelationId).to receive(:current_id).and_return(correlation_id) + allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return(correlation_id) allow(Gitlab).to receive(:process_name).and_return(process_name) expect(described_class.tracing_url).to eq(tracing_url) |