Commit 6af84964 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Set cache expire only once the cache is filled,

 to avoid situation where old result is returned in parallel thread.
parent b503e6ff
...@@ -20,10 +20,13 @@ module Gitlab ...@@ -20,10 +20,13 @@ module Gitlab
def self.call_measurement_enabled? def self.call_measurement_enabled?
return @call_measurement_enabled unless call_measurement_enabled_cache_expired? return @call_measurement_enabled unless call_measurement_enabled_cache_expired?
MUTEX.synchronize do MUTEX.synchronize do
return @call_measurement_enabled unless call_measurement_enabled_cache_expired? 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 = Feature.get(:prometheus_metrics_method_instrumentation).enabled?
@call_measurement_enabled_cache_expires_at = Time.now + 5.minutes
@call_measurement_enabled
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment