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:
Diffstat (limited to 'lib/gitlab/utils/usage_data.rb')
-rw-r--r--lib/gitlab/utils/usage_data.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/gitlab/utils/usage_data.rb b/lib/gitlab/utils/usage_data.rb
index afc4e000977..625e1076a54 100644
--- a/lib/gitlab/utils/usage_data.rb
+++ b/lib/gitlab/utils/usage_data.rb
@@ -77,11 +77,11 @@ module Gitlab
end
end
- def with_prometheus_client
- if Gitlab::Prometheus::Internal.prometheus_enabled?
- prometheus_address = Gitlab::Prometheus::Internal.uri
- yield Gitlab::PrometheusClient.new(prometheus_address, allow_local_requests: true)
- end
+ def with_prometheus_client(fallback: nil)
+ return fallback unless Gitlab::Prometheus::Internal.prometheus_enabled?
+
+ prometheus_address = Gitlab::Prometheus::Internal.uri
+ yield Gitlab::PrometheusClient.new(prometheus_address, allow_local_requests: true)
end
def measure_duration
@@ -92,6 +92,10 @@ module Gitlab
[result, duration]
end
+ def with_finished_at(key, &block)
+ yield.merge(key => Time.now)
+ end
+
private
def redis_usage_counter