Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 11:17:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 11:17:02 +0300
commitb39512ed755239198a9c294b6a45e65c05900235 (patch)
treed234a3efade1de67c46b9e5a38ce813627726aa7 /lib/gitlab/instrumentation/global_search_api.rb
parentd31474cf3b17ece37939d20082b07f6657cc79a9 (diff)
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'lib/gitlab/instrumentation/global_search_api.rb')
-rw-r--r--lib/gitlab/instrumentation/global_search_api.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/gitlab/instrumentation/global_search_api.rb b/lib/gitlab/instrumentation/global_search_api.rb
new file mode 100644
index 00000000000..ea2f5702364
--- /dev/null
+++ b/lib/gitlab/instrumentation/global_search_api.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Instrumentation
+ class GlobalSearchApi
+ TYPE = 'meta.search.type'
+ LEVEL = 'meta.search.level'
+ SCOPE = 'meta.search.scope'
+ SEARCH_DURATION_S = :global_search_duration_s
+
+ def self.get_type
+ ::Gitlab::SafeRequestStore[TYPE]
+ end
+
+ def self.get_level
+ ::Gitlab::SafeRequestStore[LEVEL]
+ end
+
+ def self.get_scope
+ ::Gitlab::SafeRequestStore[SCOPE]
+ end
+
+ def self.get_search_duration_s
+ ::Gitlab::SafeRequestStore[SEARCH_DURATION_S]
+ end
+
+ def self.payload
+ {
+ TYPE => get_type,
+ LEVEL => get_level,
+ SCOPE => get_scope,
+ SEARCH_DURATION_S => get_search_duration_s
+ }.compact
+ end
+
+ 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
+ end
+ end
+end