diff options
author | Andrew Newdigate <andrew@gitlab.com> | 2019-02-18 22:57:22 +0200 |
---|---|---|
committer | Andrew Newdigate <andrew@gitlab.com> | 2019-04-18 09:57:16 +0200 |
commit | 4f4de36cacbcd137e9db2a7b1449bb803bf1f395 (patch) | |
tree | 7514b0a3c310091bf0b909fc9544968fbe4619ab /spec | |
parent | d9e5edf198803aded681cb900c50bc454fade7f3 (diff) | |
download | gitlab-ce-4f4de36cacbcd137e9db2a7b1449bb803bf1f395.tar.gz |
Migrate correlation and tracing code to LabKitan-use-labkit
This change is a fairly straightforward refactor to extract the tracing
and correlation-id code from the gitlab rails codebase into the new
LabKit-Ruby project.
The corresponding import into LabKit-Ruby was in
https://gitlab.com/gitlab-org/labkit-ruby/merge_requests/1
The code itself remains very similar for now.
Extracting it allows us to reuse it in other projects, such as
Gitaly-Ruby. This will give us the advantages of correlation-ids and
distributed tracing in that project too.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/correlation_id_spec.rb | 77 | ||||
-rw-r--r-- | spec/lib/gitlab/json_logger_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/sentry_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing/factory_spec.rb | 43 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing/grpc_interceptor_spec.rb | 47 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing/jaeger_factory_spec.rb | 71 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing/rack_middleware_spec.rb | 62 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing/rails/action_view_subscriber_spec.rb | 147 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing/rails/active_record_subscriber_spec.rb | 73 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing/sidekiq/client_middleware_spec.rb | 43 | ||||
-rw-r--r-- | spec/lib/gitlab/tracing/sidekiq/server_middleware_spec.rb | 43 | ||||
-rw-r--r-- | spec/requests/api/helpers_spec.rb | 2 |
15 files changed, 7 insertions, 613 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index a5ecb475ce3..7296a4b4526 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -462,7 +462,7 @@ describe ApplicationController do end it 'does log correlation id' do - Gitlab::CorrelationId.use_id('new-id') do + Labkit::Correlation::CorrelationId.use_id('new-id') do get :index end diff --git a/spec/lib/gitlab/correlation_id_spec.rb b/spec/lib/gitlab/correlation_id_spec.rb deleted file mode 100644 index 584d1f48386..00000000000 --- a/spec/lib/gitlab/correlation_id_spec.rb +++ /dev/null @@ -1,77 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' - -describe Gitlab::CorrelationId do - describe '.use_id' do - it 'yields when executed' do - expect { |blk| described_class.use_id('id', &blk) }.to yield_control - end - - it 'stacks correlation ids' do - described_class.use_id('id1') do - described_class.use_id('id2') do |current_id| - expect(current_id).to eq('id2') - end - end - end - - it 'for missing correlation id it generates random one' do - described_class.use_id('id1') do - described_class.use_id(nil) do |current_id| - expect(current_id).not_to be_empty - expect(current_id).not_to eq('id1') - end - end - end - end - - describe '.current_id' do - subject { described_class.current_id } - - it 'returns last correlation id' do - described_class.use_id('id1') do - described_class.use_id('id2') do - is_expected.to eq('id2') - end - end - end - end - - describe '.current_or_new_id' do - subject { described_class.current_or_new_id } - - context 'when correlation id is set' do - it 'returns last correlation id' do - described_class.use_id('id1') do - is_expected.to eq('id1') - end - end - end - - context 'when correlation id is missing' do - it 'returns a new correlation id' do - expect(described_class).to receive(:new_id) - .and_call_original - - is_expected.not_to be_empty - end - end - end - - describe '.ids' do - subject { described_class.send(:ids) } - - it 'returns empty list if not correlation is used' do - is_expected.to be_empty - end - - it 'returns list if correlation ids are used' do - described_class.use_id('id1') do - described_class.use_id('id2') do - is_expected.to eq(%w(id1 id2)) - end - end - end - end -end diff --git a/spec/lib/gitlab/json_logger_spec.rb b/spec/lib/gitlab/json_logger_spec.rb index cff7dd58c8c..d3d9fe9948a 100644 --- a/spec/lib/gitlab/json_logger_spec.rb +++ b/spec/lib/gitlab/json_logger_spec.rb @@ -8,7 +8,7 @@ describe Gitlab::JsonLogger do describe '#format_message' do before do - allow(Gitlab::CorrelationId).to receive(:current_id).and_return('new-correlation-id') + allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return('new-correlation-id') end it 'formats strings' do diff --git a/spec/lib/gitlab/sentry_spec.rb b/spec/lib/gitlab/sentry_spec.rb index 1128eaf8560..ae522a588ee 100644 --- a/spec/lib/gitlab/sentry_spec.rb +++ b/spec/lib/gitlab/sentry_spec.rb @@ -27,7 +27,7 @@ describe Gitlab::Sentry do context 'when exceptions should not be raised' do before do allow(described_class).to receive(:should_raise_for_dev?).and_return(false) - allow(Gitlab::CorrelationId).to receive(:current_id).and_return('cid') + allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return('cid') end it 'logs the exception with all attributes passed' do @@ -65,7 +65,7 @@ describe Gitlab::Sentry do before do allow(described_class).to receive(:enabled?).and_return(true) - allow(Gitlab::CorrelationId).to receive(:current_id).and_return('cid') + allow(Labkit::Correlation::CorrelationId).to receive(:current_id).and_return('cid') end it 'calls Raven.capture_exception' do diff --git a/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb b/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb index a138ad7c910..0ff694d409b 100644 --- a/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb @@ -30,7 +30,7 @@ describe Gitlab::SidekiqMiddleware::CorrelationInjector do it 'injects into payload the correlation id' do expect_any_instance_of(described_class).to receive(:call).and_call_original - Gitlab::CorrelationId.use_id('new-correlation-id') do + Labkit::Correlation::CorrelationId.use_id('new-correlation-id') do TestWorker.perform_async(1234) end diff --git a/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb b/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb index 94ae4ffa184..8410467ef1f 100644 --- a/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb @@ -23,7 +23,7 @@ describe Gitlab::SidekiqMiddleware::CorrelationLogger do expect_any_instance_of(described_class).to receive(:call).and_call_original expect_any_instance_of(TestWorker).to receive(:perform).with(1234) do - expect(Gitlab::CorrelationId.current_id).to eq('new-correlation-id') + expect(Labkit::Correlation::CorrelationId.current_id).to eq('new-correlation-id') end Sidekiq::Client.push( diff --git a/spec/lib/gitlab/tracing/factory_spec.rb b/spec/lib/gitlab/tracing/factory_spec.rb deleted file mode 100644 index 945490f0988..00000000000 --- a/spec/lib/gitlab/tracing/factory_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' - -describe Gitlab::Tracing::Factory do - describe '.create_tracer' do - let(:service_name) { 'rspec' } - - context "when tracing is not configured" do - it 'ignores null connection strings' do - expect(described_class.create_tracer(service_name, nil)).to be_nil - end - - it 'ignores empty connection strings' do - expect(described_class.create_tracer(service_name, '')).to be_nil - end - - it 'ignores unknown implementations' do - expect(described_class.create_tracer(service_name, 'opentracing://invalid_driver')).to be_nil - end - - it 'ignores invalid connection strings' do - expect(described_class.create_tracer(service_name, 'open?tracing')).to be_nil - end - end - - context "when tracing is configured with jaeger" do - let(:mock_tracer) { double('tracer') } - - it 'processes default connections' do - expect(Gitlab::Tracing::JaegerFactory).to receive(:create_tracer).with(service_name, {}).and_return(mock_tracer) - - expect(described_class.create_tracer(service_name, 'opentracing://jaeger')).to be(mock_tracer) - end - - it 'processes connections with parameters' do - expect(Gitlab::Tracing::JaegerFactory).to receive(:create_tracer).with(service_name, { a: '1', b: '2', c: '3' }).and_return(mock_tracer) - - expect(described_class.create_tracer(service_name, 'opentracing://jaeger?a=1&b=2&c=3')).to be(mock_tracer) - end - end - end -end diff --git a/spec/lib/gitlab/tracing/grpc_interceptor_spec.rb b/spec/lib/gitlab/tracing/grpc_interceptor_spec.rb deleted file mode 100644 index 7f5aecb7baa..00000000000 --- a/spec/lib/gitlab/tracing/grpc_interceptor_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' - -describe Gitlab::Tracing::GRPCInterceptor do - subject { described_class.instance } - - shared_examples_for "a grpc interceptor method" do - let(:custom_error) { Class.new(StandardError) } - - it 'yields' do - expect { |b| method.call(kwargs, &b) }.to yield_control - end - - it 'propagates exceptions' do - expect { method.call(kwargs) { raise custom_error } }.to raise_error(custom_error) - end - end - - describe '#request_response' do - let(:method) { subject.method(:request_response) } - let(:kwargs) { { request: {}, call: {}, method: 'grc_method', metadata: {} } } - - it_behaves_like 'a grpc interceptor method' - end - - describe '#client_streamer' do - let(:method) { subject.method(:client_streamer) } - let(:kwargs) { { requests: [], call: {}, method: 'grc_method', metadata: {} } } - - it_behaves_like 'a grpc interceptor method' - end - - describe '#server_streamer' do - let(:method) { subject.method(:server_streamer) } - let(:kwargs) { { request: {}, call: {}, method: 'grc_method', metadata: {} } } - - it_behaves_like 'a grpc interceptor method' - end - - describe '#bidi_streamer' do - let(:method) { subject.method(:bidi_streamer) } - let(:kwargs) { { requests: [], call: {}, method: 'grc_method', metadata: {} } } - - it_behaves_like 'a grpc interceptor method' - end -end diff --git a/spec/lib/gitlab/tracing/jaeger_factory_spec.rb b/spec/lib/gitlab/tracing/jaeger_factory_spec.rb deleted file mode 100644 index 3d6a007cfd9..00000000000 --- a/spec/lib/gitlab/tracing/jaeger_factory_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' - -describe Gitlab::Tracing::JaegerFactory do - describe '.create_tracer' do - let(:service_name) { 'rspec' } - - shared_examples_for 'a jaeger tracer' do - it 'responds to active_span methods' do - expect(tracer).to respond_to(:active_span) - end - - it 'yields control' do - expect { |b| tracer.start_active_span('operation_name', &b) }.to yield_control - end - end - - context 'processes default connections' do - it_behaves_like 'a jaeger tracer' do - let(:tracer) { described_class.create_tracer(service_name, {}) } - end - end - - context 'handles debug options' do - it_behaves_like 'a jaeger tracer' do - let(:tracer) { described_class.create_tracer(service_name, { debug: "1" }) } - end - end - - context 'handles const sampler' do - it_behaves_like 'a jaeger tracer' do - let(:tracer) { described_class.create_tracer(service_name, { sampler: "const", sampler_param: "1" }) } - end - end - - context 'handles probabilistic sampler' do - it_behaves_like 'a jaeger tracer' do - let(:tracer) { described_class.create_tracer(service_name, { sampler: "probabilistic", sampler_param: "0.5" }) } - end - end - - context 'handles http_endpoint configurations' do - it_behaves_like 'a jaeger tracer' do - let(:tracer) { described_class.create_tracer(service_name, { http_endpoint: "http://localhost:1234" }) } - end - end - - context 'handles udp_endpoint configurations' do - it_behaves_like 'a jaeger tracer' do - let(:tracer) { described_class.create_tracer(service_name, { udp_endpoint: "localhost:4321" }) } - end - end - - context 'ignores invalid parameters' do - it_behaves_like 'a jaeger tracer' do - let(:tracer) { described_class.create_tracer(service_name, { invalid: "true" }) } - end - end - - context 'accepts the debug parameter when strict_parser is set' do - it_behaves_like 'a jaeger tracer' do - let(:tracer) { described_class.create_tracer(service_name, { debug: "1", strict_parsing: "1" }) } - end - end - - it 'rejects invalid parameters when strict_parser is set' do - expect { described_class.create_tracer(service_name, { invalid: "true", strict_parsing: "1" }) }.to raise_error(StandardError) - end - end -end diff --git a/spec/lib/gitlab/tracing/rack_middleware_spec.rb b/spec/lib/gitlab/tracing/rack_middleware_spec.rb deleted file mode 100644 index 13d4d8a89f7..00000000000 --- a/spec/lib/gitlab/tracing/rack_middleware_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe Gitlab::Tracing::RackMiddleware do - using RSpec::Parameterized::TableSyntax - - describe '#call' do - context 'for normal middleware flow' do - let(:fake_app) { -> (env) { fake_app_response } } - subject { described_class.new(fake_app) } - let(:request) { } - - context 'for 200 responses' do - let(:fake_app_response) { [200, { 'Content-Type': 'text/plain' }, ['OK']] } - - it 'delegates correctly' do - expect(subject.call(Rack::MockRequest.env_for("/"))).to eq(fake_app_response) - end - end - - context 'for 500 responses' do - let(:fake_app_response) { [500, { 'Content-Type': 'text/plain' }, ['Error']] } - - it 'delegates correctly' do - expect(subject.call(Rack::MockRequest.env_for("/"))).to eq(fake_app_response) - end - end - end - - context 'when an application is raising an exception' do - let(:custom_error) { Class.new(StandardError) } - let(:fake_app) { ->(env) { raise custom_error } } - - subject { described_class.new(fake_app) } - - it 'delegates propagates exceptions correctly' do - expect { subject.call(Rack::MockRequest.env_for("/")) }.to raise_error(custom_error) - end - end - end - - describe '.build_sanitized_url_from_env' do - def env_for_url(url) - env = Rack::MockRequest.env_for(input_url) - env['action_dispatch.parameter_filter'] = [/token/] - - env - end - - where(:input_url, :output_url) do - '/gitlab-org/gitlab-ce' | 'http://example.org/gitlab-org/gitlab-ce' - '/gitlab-org/gitlab-ce?safe=1' | 'http://example.org/gitlab-org/gitlab-ce?safe=1' - '/gitlab-org/gitlab-ce?private_token=secret' | 'http://example.org/gitlab-org/gitlab-ce?private_token=%5BFILTERED%5D' - '/gitlab-org/gitlab-ce?mixed=1&private_token=secret' | 'http://example.org/gitlab-org/gitlab-ce?mixed=1&private_token=%5BFILTERED%5D' - end - - with_them do - it { expect(described_class.build_sanitized_url_from_env(env_for_url(input_url))).to eq(output_url) } - end - end -end diff --git a/spec/lib/gitlab/tracing/rails/action_view_subscriber_spec.rb b/spec/lib/gitlab/tracing/rails/action_view_subscriber_spec.rb deleted file mode 100644 index 0bbaf5968ed..00000000000 --- a/spec/lib/gitlab/tracing/rails/action_view_subscriber_spec.rb +++ /dev/null @@ -1,147 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' -require 'rspec-parameterized' - -describe Gitlab::Tracing::Rails::ActionViewSubscriber do - using RSpec::Parameterized::TableSyntax - - shared_examples 'an actionview notification' do - it 'notifies the tracer when the hash contains null values' do - expect(subject).to receive(:postnotify_span).with(notification_name, start, finish, tags: expected_tags, exception: exception) - - subject.public_send(notify_method, start, finish, payload) - end - - it 'notifies the tracer when the payload is missing values' do - expect(subject).to receive(:postnotify_span).with(notification_name, start, finish, tags: expected_tags, exception: exception) - - subject.public_send(notify_method, start, finish, payload.compact) - end - - it 'does not throw exceptions when with the default tracer' do - expect { subject.public_send(notify_method, start, finish, payload) }.not_to raise_error - end - end - - describe '.instrument' do - it 'is unsubscribeable' do - unsubscribe = described_class.instrument - - expect(unsubscribe).not_to be_nil - expect { unsubscribe.call }.not_to raise_error - end - end - - describe '#notify_render_template' do - subject { described_class.new } - let(:start) { Time.now } - let(:finish) { Time.now } - let(:notification_name) { 'render_template' } - let(:notify_method) { :notify_render_template } - - where(:identifier, :layout, :exception) do - nil | nil | nil - "" | nil | nil - "show.haml" | nil | nil - nil | "" | nil - nil | "layout.haml" | nil - nil | nil | StandardError.new - end - - with_them do - let(:payload) do - { - exception: exception, - identifier: identifier, - layout: layout - } - end - - let(:expected_tags) do - { - 'component' => 'ActionView', - 'template.id' => identifier, - 'template.layout' => layout - } - end - - it_behaves_like 'an actionview notification' - end - end - - describe '#notify_render_collection' do - subject { described_class.new } - let(:start) { Time.now } - let(:finish) { Time.now } - let(:notification_name) { 'render_collection' } - let(:notify_method) { :notify_render_collection } - - where( - :identifier, :count, :expected_count, :cache_hits, :expected_cache_hits, :exception) do - nil | nil | 0 | nil | 0 | nil - "" | nil | 0 | nil | 0 | nil - "show.haml" | nil | 0 | nil | 0 | nil - nil | 0 | 0 | nil | 0 | nil - nil | 1 | 1 | nil | 0 | nil - nil | nil | 0 | 0 | 0 | nil - nil | nil | 0 | 1 | 1 | nil - nil | nil | 0 | nil | 0 | StandardError.new - end - - with_them do - let(:payload) do - { - exception: exception, - identifier: identifier, - count: count, - cache_hits: cache_hits - } - end - - let(:expected_tags) do - { - 'component' => 'ActionView', - 'template.id' => identifier, - 'template.count' => expected_count, - 'template.cache.hits' => expected_cache_hits - } - end - - it_behaves_like 'an actionview notification' - end - end - - describe '#notify_render_partial' do - subject { described_class.new } - let(:start) { Time.now } - let(:finish) { Time.now } - let(:notification_name) { 'render_partial' } - let(:notify_method) { :notify_render_partial } - - where(:identifier, :exception) do - nil | nil - "" | nil - "show.haml" | nil - nil | StandardError.new - end - - with_them do - let(:payload) do - { - exception: exception, - identifier: identifier - } - end - - let(:expected_tags) do - { - 'component' => 'ActionView', - 'template.id' => identifier - } - end - - it_behaves_like 'an actionview notification' - end - end -end diff --git a/spec/lib/gitlab/tracing/rails/active_record_subscriber_spec.rb b/spec/lib/gitlab/tracing/rails/active_record_subscriber_spec.rb deleted file mode 100644 index 7bd0875fa68..00000000000 --- a/spec/lib/gitlab/tracing/rails/active_record_subscriber_spec.rb +++ /dev/null @@ -1,73 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' -require 'rspec-parameterized' - -describe Gitlab::Tracing::Rails::ActiveRecordSubscriber do - using RSpec::Parameterized::TableSyntax - - describe '.instrument' do - it 'is unsubscribeable' do - unsubscribe = described_class.instrument - - expect(unsubscribe).not_to be_nil - expect { unsubscribe.call }.not_to raise_error - end - end - - describe '#notify' do - subject { described_class.new } - let(:start) { Time.now } - let(:finish) { Time.now } - - where(:name, :operation_name, :exception, :connection_id, :cached, :cached_response, :sql) do - nil | "active_record:sqlquery" | nil | nil | nil | false | nil - "" | "active_record:sqlquery" | nil | nil | nil | false | nil - "User Load" | "active_record:User Load" | nil | nil | nil | false | nil - "Repo Load" | "active_record:Repo Load" | StandardError.new | nil | nil | false | nil - nil | "active_record:sqlquery" | nil | 123 | nil | false | nil - nil | "active_record:sqlquery" | nil | nil | false | false | nil - nil | "active_record:sqlquery" | nil | nil | true | true | nil - nil | "active_record:sqlquery" | nil | nil | true | true | "SELECT * FROM users" - end - - with_them do - def payload - { - name: name, - exception: exception, - connection_id: connection_id, - cached: cached, - sql: sql - } - end - - def expected_tags - { - "component" => "ActiveRecord", - "span.kind" => "client", - "db.type" => "sql", - "db.connection_id" => connection_id, - "db.cached" => cached_response, - "db.statement" => sql - } - end - - it 'notifies the tracer when the hash contains null values' do - expect(subject).to receive(:postnotify_span).with(operation_name, start, finish, tags: expected_tags, exception: exception) - - subject.notify(start, finish, payload) - end - - it 'notifies the tracer when the payload is missing values' do - expect(subject).to receive(:postnotify_span).with(operation_name, start, finish, tags: expected_tags, exception: exception) - - subject.notify(start, finish, payload.compact) - end - - it 'does not throw exceptions when with the default tracer' do - expect { subject.notify(start, finish, payload) }.not_to raise_error - end - end - end -end diff --git a/spec/lib/gitlab/tracing/sidekiq/client_middleware_spec.rb b/spec/lib/gitlab/tracing/sidekiq/client_middleware_spec.rb deleted file mode 100644 index 3755860b5ba..00000000000 --- a/spec/lib/gitlab/tracing/sidekiq/client_middleware_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' - -describe Gitlab::Tracing::Sidekiq::ClientMiddleware do - describe '#call' do - let(:worker_class) { 'test_worker_class' } - let(:job) do - { - 'class' => "jobclass", - 'queue' => "jobqueue", - 'retry' => 0, - 'args' => %w{1 2 3} - } - end - let(:queue) { 'test_queue' } - let(:redis_pool) { double("redis_pool") } - let(:custom_error) { Class.new(StandardError) } - let(:span) { OpenTracing.start_span('test', ignore_active_scope: true) } - - subject { described_class.new } - - it 'yields' do - expect(subject).to receive(:in_tracing_span).with( - operation_name: "sidekiq:jobclass", - tags: { - "component" => "sidekiq", - "span.kind" => "client", - "sidekiq.queue" => "jobqueue", - "sidekiq.jid" => nil, - "sidekiq.retry" => "0", - "sidekiq.args" => "1, 2, 3" - } - ).and_yield(span) - - expect { |b| subject.call(worker_class, job, queue, redis_pool, &b) }.to yield_control - end - - it 'propagates exceptions' do - expect { subject.call(worker_class, job, queue, redis_pool) { raise custom_error } }.to raise_error(custom_error) - end - end -end diff --git a/spec/lib/gitlab/tracing/sidekiq/server_middleware_spec.rb b/spec/lib/gitlab/tracing/sidekiq/server_middleware_spec.rb deleted file mode 100644 index c3087de785a..00000000000 --- a/spec/lib/gitlab/tracing/sidekiq/server_middleware_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' - -describe Gitlab::Tracing::Sidekiq::ServerMiddleware do - describe '#call' do - let(:worker_class) { 'test_worker_class' } - let(:job) do - { - 'class' => "jobclass", - 'queue' => "jobqueue", - 'retry' => 0, - 'args' => %w{1 2 3} - } - end - let(:queue) { 'test_queue' } - let(:custom_error) { Class.new(StandardError) } - let(:span) { OpenTracing.start_span('test', ignore_active_scope: true) } - subject { described_class.new } - - it 'yields' do - expect(subject).to receive(:in_tracing_span).with( - hash_including( - operation_name: "sidekiq:jobclass", - tags: { - "component" => "sidekiq", - "span.kind" => "server", - "sidekiq.queue" => "jobqueue", - "sidekiq.jid" => nil, - "sidekiq.retry" => "0", - "sidekiq.args" => "1, 2, 3" - } - ) - ).and_yield(span) - - expect { |b| subject.call(worker_class, job, queue, &b) }.to yield_control - end - - it 'propagates exceptions' do - expect { subject.call(worker_class, job, queue) { raise custom_error } }.to raise_error(custom_error) - end - end -end diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index a0c64d295c0..25a312cb734 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -251,7 +251,7 @@ describe API::Helpers do correlation_id: 'new-correlation-id' }, extra: {}) - Gitlab::CorrelationId.use_id('new-correlation-id') do + Labkit::Correlation::CorrelationId.use_id('new-correlation-id') do handle_api_exception(exception) end end |