summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-12-08 20:19:01 +0100
committerPawel Chojnacki <pawel@chojnacki.ws>2017-12-12 18:38:28 +0100
commit6af849644dd097f7b41a26ca8b49d274444db196 (patch)
treefef07b5ba5bd988d016ac932dffc7d668d6ad9c1
parentb503e6ff423699f7556fb948051e9c180a7b89f0 (diff)
downloadgitlab-ce-6af849644dd097f7b41a26ca8b49d274444db196.tar.gz
Set cache expire only once the cache is filled,
to avoid situation where old result is returned in parallel thread.
-rw-r--r--lib/gitlab/metrics/method_call.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/gitlab/metrics/method_call.rb b/lib/gitlab/metrics/method_call.rb
index 744c489d46e..2f5c45966ff 100644
--- a/lib/gitlab/metrics/method_call.rb
+++ b/lib/gitlab/metrics/method_call.rb
@@ -20,10 +20,13 @@ module Gitlab
def self.call_measurement_enabled?
return @call_measurement_enabled unless call_measurement_enabled_cache_expired?
+
MUTEX.synchronize do
return @call_measurement_enabled unless call_measurement_enabled_cache_expired?
- @call_measurement_enabled_cache_expires_at = Time.now + 5.minutes
+
@call_measurement_enabled = Feature.get(:prometheus_metrics_method_instrumentation).enabled?
+ @call_measurement_enabled_cache_expires_at = Time.now + 5.minutes
+ @call_measurement_enabled
end
end