Commit e52bf66b authored by Kamil Trzciński's avatar Kamil Trzciński

Improve readibility of `already_within?`

The prior `return if enabled_analyzers` was
a pretty criptic way to indicate nested calls.
This makes this concept clear with reasons.
parent 717a1010
......@@ -31,7 +31,10 @@ module Gitlab
end
def within
return yield if enabled_analyzers
# Due to singleton nature of analyzers
# only an outer invocation of the `.within`
# is allowed to initialize them
return yield if already_within?
begin!
......@@ -42,6 +45,11 @@ module Gitlab
end
end
def already_within?
# If analyzers are set they are already configured
!enabled_analyzers.nil?
end
def process_sql(sql, connection)
analyzers = enabled_analyzers
return unless analyzers&.any?
......@@ -69,6 +77,8 @@ module Gitlab
end
rescue StandardError => e
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
false
end
Thread.current[:query_analyzer_enabled_analyzers] = analyzers
......
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