Class: Gitlab::Database::QueryAnalyzers::Base
- Inherits:
-
Object
- Object
- Gitlab::Database::QueryAnalyzers::Base
show all
- Defined in:
- lib/gitlab/database/query_analyzers/base.rb
Constant Summary
collapse
- QueryAnalyzerError =
`Exception` to ensure that is not easily rescued when running in test env
Class.new(Exception)
Class Method Summary
collapse
Class Method Details
.analyze(parsed) ⇒ Object
46
47
48
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 46
def self.analyze(parsed)
raise NotImplementedError
end
|
.analyzer_key ⇒ Object
58
59
60
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 58
def self.analyzer_key
@analyzer_key ||= self.name.demodulize.underscore.to_sym
end
|
.begin! ⇒ Object
30
31
32
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 30
def self.begin!
Thread.current[self.context_key] = {}
end
|
.context ⇒ Object
38
39
40
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 38
def self.context
Thread.current[self.context_key]
end
|
.context_key ⇒ Object
50
51
52
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 50
def self.context_key
@context_key ||= "analyzer_#{self.analyzer_key}_context".to_sym
end
|
.enabled? ⇒ Boolean
42
43
44
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 42
def self.enabled?
raise NotImplementedError
end
|
.end! ⇒ Object
34
35
36
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 34
def self.end!
Thread.current[self.context_key] = nil
end
|
.requires_tracking?(parsed) ⇒ Boolean
14
15
16
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 14
def self.requires_tracking?(parsed)
false
end
|
.suppress=(value) ⇒ Object
18
19
20
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 18
def self.suppress=(value)
Thread.current[self.suppress_key] = value
end
|
.suppress_key ⇒ Object
54
55
56
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 54
def self.suppress_key
@suppress_key ||= "analyzer_#{self.analyzer_key}_suppressed".to_sym
end
|
.suppressed? ⇒ Boolean
10
11
12
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 10
def self.suppressed?
Thread.current[self.suppress_key]
end
|
.with_suppressed(value = true, &blk) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/gitlab/database/query_analyzers/base.rb', line 22
def self.with_suppressed(value = true, &blk)
previous = self.suppressed?
self.suppress = value
yield
ensure
self.suppress = previous
end
|