Commit c6b4adcd authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'only-report-mystery-duration-error-for-shared-state' into 'master'

Only report MysteryRedisDurationError for shared state Redis

See merge request gitlab-org/gitlab!69446
parents 31f3eb8c 3e7343b1
......@@ -41,7 +41,10 @@ module Gitlab
instrumentation_class.add_call_details(duration, args)
end
if duration > DURATION_ERROR_THRESHOLD && Feature.enabled?(:report_on_long_redis_durations, default_enabled: :yaml)
if duration > DURATION_ERROR_THRESHOLD &&
instrumentation_class == ::Gitlab::Instrumentation::Redis::SharedState &&
Feature.enabled?(:report_on_long_redis_durations, default_enabled: :yaml)
Gitlab::ErrorTracking.track_exception(MysteryRedisDurationError.new(caller),
command: command_from_args(args),
duration: duration,
......
......@@ -130,6 +130,15 @@ RSpec.describe Gitlab::Instrumentation::RedisInterceptor, :clean_gitlab_redis_sh
end
context 'when report_on_long_redis_durations is enabled' do
context 'for an instance other than SharedState' do
it 'does nothing' do
expect(Gitlab::ErrorTracking).not_to receive(:track_exception)
Gitlab::Redis::Queues.with { |r| r.mget('foo', 'foo') { sleep threshold + 0.1 } }
end
end
context 'for the SharedState instance' do
it 'tracks an exception and continues' do
expect(Gitlab::ErrorTracking)
.to receive(:track_exception)
......@@ -142,4 +151,5 @@ RSpec.describe Gitlab::Instrumentation::RedisInterceptor, :clean_gitlab_redis_sh
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment