Class: Gitlab::Instrumentation::GlobalSearchApi

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/instrumentation/global_search_api.rb

Constant Summary collapse

TYPE =
'meta.search.type'
LEVEL =
'meta.search.level'
SCOPE =
'meta.search.scope'
SEARCH_DURATION_S =
:global_search_duration_s

Class Method Summary collapse

Class Method Details

.get_levelObject



15
16
17
# File 'lib/gitlab/instrumentation/global_search_api.rb', line 15

def self.get_level
  ::Gitlab::SafeRequestStore[LEVEL]
end

.get_scopeObject



19
20
21
# File 'lib/gitlab/instrumentation/global_search_api.rb', line 19

def self.get_scope
  ::Gitlab::SafeRequestStore[SCOPE]
end

.get_search_duration_sObject



23
24
25
# File 'lib/gitlab/instrumentation/global_search_api.rb', line 23

def self.get_search_duration_s
  ::Gitlab::SafeRequestStore[SEARCH_DURATION_S]
end

.get_typeObject



11
12
13
# File 'lib/gitlab/instrumentation/global_search_api.rb', line 11

def self.get_type
  ::Gitlab::SafeRequestStore[TYPE]
end

.payloadObject



27
28
29
30
31
32
33
34
# File 'lib/gitlab/instrumentation/global_search_api.rb', line 27

def self.payload
  {
    TYPE => get_type,
    LEVEL => get_level,
    SCOPE => get_scope,
    SEARCH_DURATION_S => get_search_duration_s
  }.compact
end

.set_information(type:, level:, scope:, search_duration_s:) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/gitlab/instrumentation/global_search_api.rb', line 36

def self.set_information(type:, level:, scope:, search_duration_s:)
  if ::Gitlab::SafeRequestStore.active?
    ::Gitlab::SafeRequestStore[TYPE] = type
    ::Gitlab::SafeRequestStore[LEVEL] = level
    ::Gitlab::SafeRequestStore[SCOPE] = scope
    ::Gitlab::SafeRequestStore[SEARCH_DURATION_S] = search_duration_s
  end
end