Fix Gitlab::Metrics metaprogramming magic
On initial startup with no rows in the application_settings table, the metaprogramming call to `if enabled?` attempts to create a row. This triggers the HTML caching path, which attempts to store metrics. At this point, not all the methods in `Gitlab::Metrics` have been defined! Move `current_transaction` to be defined before running the metaprogramming, to avoid a confusing NoMethodError
This commit is contained in:
parent
bc14c4f03b
commit
6647542cd4
1 changed files with 5 additions and 5 deletions
|
@ -138,6 +138,11 @@ module Gitlab
|
||||||
@series_prefix ||= Sidekiq.server? ? 'sidekiq_' : 'rails_'
|
@series_prefix ||= Sidekiq.server? ? 'sidekiq_' : 'rails_'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Allow access from other metrics related middlewares
|
||||||
|
def self.current_transaction
|
||||||
|
Transaction.current
|
||||||
|
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 enabled?
|
if enabled?
|
||||||
|
@ -149,10 +154,5 @@ module Gitlab
|
||||||
new(udp: { host: host, port: port })
|
new(udp: { host: host, port: port })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Allow access from other metrics related middlewares
|
|
||||||
def self.current_transaction
|
|
||||||
Transaction.current
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue