Commit 517838e0 authored by Pawel Chojnacki's avatar Pawel Chojnacki
Browse files

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.
parent bef34fb79913
module Gitlab
module Metrics
module InfluxDb
include Gitlab::CurrentSettings
extend Gitlab::CurrentSettings
extend self
MUTEX = Mutex.new
private_constant :MUTEX
def influx_metrics_enabled?
settings[:enabled] || false
......@@ -35,10 +39,6 @@
@method_call_threshold ||= settings[:method_call_threshold]
end
def pool
@pool
end
def submit_metrics(metrics)
prepared = prepare_metrics(metrics)
......@@ -143,9 +143,9 @@
end
# Allow access from other metrics related middlewares
def current_transaction
def current_transaction
Transaction.current
end
# When enabled this should be set before being used as the usual pattern
# "@foo ||= bar" is _not_ thread-safe.
......@@ -147,10 +147,13 @@
Transaction.current
end
# When enabled this should be set before being used as the usual pattern
# "@foo ||= bar" is _not_ thread-safe.
if influx_metrics_enabled?
@pool = ConnectionPool.new(size: settings[:pool_size], timeout: settings[:timeout]) do
host = settings[:host]
port = settings[:port]
def pool
if influx_metrics_enabled?
if @pool.nil?
MUTEX.synchronize do
@pool ||= ConnectionPool.new(size: settings[:pool_size], timeout: settings[:timeout]) do
host = settings[:host]
port = settings[:port]
......@@ -156,7 +159,11 @@
InfluxDB::Client.
new(udp: { host: host, port: port })
InfluxDB::Client.
new(udp: { host: host, port: port })
end
end
end
@pool
end
end
end
end
......@@ -159,5 +166,5 @@
end
end
end
end
end
\ No newline at end of file
end
Supports Markdown
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