summaryrefslogtreecommitdiff
path: root/lib/gitlab/metrics/subscribers/external_http.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/metrics/subscribers/external_http.rb')
-rw-r--r--lib/gitlab/metrics/subscribers/external_http.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/gitlab/metrics/subscribers/external_http.rb b/lib/gitlab/metrics/subscribers/external_http.rb
index a5bfc80b3bf..87756b14887 100644
--- a/lib/gitlab/metrics/subscribers/external_http.rb
+++ b/lib/gitlab/metrics/subscribers/external_http.rb
@@ -6,8 +6,6 @@ module Gitlab
# Class for tracking the total time spent in external HTTP
# See more at https://gitlab.com/gitlab-org/labkit-ruby/-/blob/v0.14.0/lib/gitlab-labkit.rb#L18
class ExternalHttp < ActiveSupport::Subscriber
- InstrumentationStorage = ::Gitlab::Instrumentation::Storage
-
attach_to :external_http
DEFAULT_STATUS_CODE = 'undefined'
@@ -21,19 +19,19 @@ module Gitlab
MAX_SLOW_REQUESTS = 10
def self.detail_store
- InstrumentationStorage[DETAIL_STORE] ||= []
+ ::Gitlab::SafeRequestStore[DETAIL_STORE] ||= []
end
def self.duration
- InstrumentationStorage[DURATION].to_f
+ Gitlab::SafeRequestStore[DURATION].to_f
end
def self.request_count
- InstrumentationStorage[COUNTER].to_i
+ Gitlab::SafeRequestStore[COUNTER].to_i
end
def self.slow_requests
- InstrumentationStorage[SLOW_REQUESTS]
+ Gitlab::SafeRequestStore[SLOW_REQUESTS]
end
def self.top_slowest_requests
@@ -84,14 +82,14 @@ module Gitlab
end
def add_to_request_store(payload)
- return unless InstrumentationStorage.active?
+ return unless Gitlab::SafeRequestStore.active?
- InstrumentationStorage[COUNTER] = InstrumentationStorage[COUNTER].to_i + 1
- InstrumentationStorage[DURATION] = InstrumentationStorage[DURATION].to_f + payload[:duration].to_f
+ Gitlab::SafeRequestStore[COUNTER] = Gitlab::SafeRequestStore[COUNTER].to_i + 1
+ Gitlab::SafeRequestStore[DURATION] = Gitlab::SafeRequestStore[DURATION].to_f + payload[:duration].to_f
if payload[:duration].to_f > THRESHOLD_SLOW_REQUEST_S
- InstrumentationStorage[SLOW_REQUESTS] ||= []
- InstrumentationStorage[SLOW_REQUESTS] << {
+ Gitlab::SafeRequestStore[SLOW_REQUESTS] ||= []
+ Gitlab::SafeRequestStore[SLOW_REQUESTS] << {
method: payload[:method],
host: payload[:host],
port: payload[:port],