diff options
author | Nick Thomas <nick@gitlab.com> | 2017-04-11 19:54:04 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-04-21 11:52:28 +0100 |
commit | 6647542cd4db5f5aba36ae7d7d029bdaf8b59a35 (patch) | |
tree | a6ba4d4bfa402220cce413528541c49e7176b0b9 | |
parent | bc14c4f03b6f735d92533f7596fadf9bd41372b6 (diff) | |
download | gitlab-ce-6647542cd4db5f5aba36ae7d7d029bdaf8b59a35.tar.gz |
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
-rw-r--r-- | lib/gitlab/metrics.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/gitlab/metrics.rb b/lib/gitlab/metrics.rb index 857e0abf710..c6dfa4ad9bd 100644 --- a/lib/gitlab/metrics.rb +++ b/lib/gitlab/metrics.rb @@ -138,6 +138,11 @@ module Gitlab @series_prefix ||= Sidekiq.server? ? 'sidekiq_' : 'rails_' 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 # "@foo ||= bar" is _not_ thread-safe. if enabled? @@ -149,10 +154,5 @@ module Gitlab new(udp: { host: host, port: port }) end end - - # Allow access from other metrics related middlewares - def self.current_transaction - Transaction.current - end end end |