Fix circular dependency condition with current_application_settings
`current_application_settings` used by `influx_metrics_enabled` executed a markdown parsing code that was measured using `Gitlab::Metrics.measure` But since the Gitlab::Metrics::InfluxDb was not yet build so Gitlab::Metrics did not yet have `measure` method. Causing the NoMethodError. However If run was successful at least once then result was cached in a file and this code never executed again. Which caused this issue to only show up in CI preparation step.
This commit is contained in:
parent
b668aaf426
commit
68b946e3c8
1 changed files with 20 additions and 13 deletions
|
@ -1,7 +1,11 @@
|
||||||
module Gitlab
|
module Gitlab
|
||||||
module Metrics
|
module Metrics
|
||||||
module InfluxDb
|
module InfluxDb
|
||||||
include Gitlab::CurrentSettings
|
extend Gitlab::CurrentSettings
|
||||||
|
extend self
|
||||||
|
|
||||||
|
MUTEX = Mutex.new
|
||||||
|
private_constant :MUTEX
|
||||||
|
|
||||||
def influx_metrics_enabled?
|
def influx_metrics_enabled?
|
||||||
settings[:enabled] || false
|
settings[:enabled] || false
|
||||||
|
@ -35,10 +39,6 @@ module Gitlab
|
||||||
@method_call_threshold ||= settings[:method_call_threshold]
|
@method_call_threshold ||= settings[:method_call_threshold]
|
||||||
end
|
end
|
||||||
|
|
||||||
def pool
|
|
||||||
@pool
|
|
||||||
end
|
|
||||||
|
|
||||||
def submit_metrics(metrics)
|
def submit_metrics(metrics)
|
||||||
prepared = prepare_metrics(metrics)
|
prepared = prepare_metrics(metrics)
|
||||||
|
|
||||||
|
@ -143,21 +143,28 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
# Allow access from other metrics related middlewares
|
# Allow access from other metrics related middlewares
|
||||||
def current_transaction
|
def current_transaction
|
||||||
Transaction.current
|
Transaction.current
|
||||||
end
|
end
|
||||||
|
|
||||||
# When enabled this should be set before being used as the usual pattern
|
# When enabled this should be set before being used as the usual pattern
|
||||||
# "@foo ||= bar" is _not_ thread-safe.
|
# "@foo ||= bar" is _not_ thread-safe.
|
||||||
if influx_metrics_enabled?
|
def pool
|
||||||
@pool = ConnectionPool.new(size: settings[:pool_size], timeout: settings[:timeout]) do
|
if influx_metrics_enabled?
|
||||||
host = settings[:host]
|
if @pool.nil?
|
||||||
port = settings[:port]
|
MUTEX.synchronize do
|
||||||
|
@pool ||= ConnectionPool.new(size: settings[:pool_size], timeout: settings[:timeout]) do
|
||||||
|
host = settings[:host]
|
||||||
|
port = settings[:port]
|
||||||
|
|
||||||
InfluxDB::Client.
|
InfluxDB::Client.
|
||||||
new(udp: { host: host, port: port })
|
new(udp: { host: host, port: port })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@pool
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue