blob: f4500a4809042b5bd9f904fd5f0a671646a0a0c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# frozen_string_literal: true
# Patch to annotate sql only when the feature is enabled.
module Gitlab
module Marginalia
module ActiveRecordInstrumentation
# CAUTION:
# Any method call which generates a query inside this function will get into a recursive loop unless called within `Marginalia.without_annotation` method.
def annotate_sql(sql)
if ActiveRecord::Base.connected? &&
::Marginalia.annotation_allowed? &&
::Marginalia.without_annotation { Gitlab::Marginalia.feature_enabled? }
super(sql)
else
sql
end
end
end
end
end
|