about summary refs log tree commit diff
path: root/config/initializers
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-07-04 16:21:39 +0200
committerThibaut Girka <thib@sitedethib.com>2019-07-04 16:21:39 +0200
commit6ab84c12a7ebc68fb8ce9a6b8228b28ec06a2c0f (patch)
tree0f023e22bcb1ae01ce3fb4e43b771609493e4e65 /config/initializers
parentc94966891af1ff456c6382595c07c2d68c57ec49 (diff)
parent99924f282f53593e670c70a38450a1c0e2d24c20 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/instrumentation.rb18
-rw-r--r--config/initializers/statsd.rb6
2 files changed, 3 insertions, 21 deletions
diff --git a/config/initializers/instrumentation.rb b/config/initializers/instrumentation.rb
deleted file mode 100644
index 8483f2be2..000000000
--- a/config/initializers/instrumentation.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-instrumentation_hostname = ENV.fetch('INSTRUMENTATION_HOSTNAME') { 'localhost' }
-
-ActiveSupport::Notifications.subscribe(/process_action.action_controller/) do |*args|
-  event      = ActiveSupport::Notifications::Event.new(*args)
-  controller = event.payload[:controller]
-  action     = event.payload[:action]
-  format     = event.payload[:format] || 'all'
-  format     = 'all' if format == '*/*'
-  status     = event.payload[:status]
-  key        = "#{controller}.#{action}.#{format}.#{instrumentation_hostname}"
-
-  ActiveSupport::Notifications.instrument :performance, action: :measure, measurement: "#{key}.total_duration", value: event.duration
-  ActiveSupport::Notifications.instrument :performance, action: :measure, measurement: "#{key}.db_time", value: event.payload[:db_runtime]
-  ActiveSupport::Notifications.instrument :performance, action: :measure, measurement: "#{key}.view_time", value: event.payload[:view_runtime]
-  ActiveSupport::Notifications.instrument :performance, measurement: "#{key}.status.#{status}"
-end
diff --git a/config/initializers/statsd.rb b/config/initializers/statsd.rb
index ce83fd9de..93ea1d1e4 100644
--- a/config/initializers/statsd.rb
+++ b/config/initializers/statsd.rb
@@ -3,10 +3,10 @@
 if ENV['STATSD_ADDR'].present?
   host, port = ENV['STATSD_ADDR'].split(':')
 
-  statsd = ::Statsd.new(host, port)
-  statsd.namespace = ENV.fetch('STATSD_NAMESPACE') { ['Mastodon', Rails.env].join('.') }
+  $statsd = ::Statsd.new(host, port)
+  $statsd.namespace = ENV.fetch('STATSD_NAMESPACE') { ['Mastodon', Rails.env].join('.') }
 
-  ::NSA.inform_statsd(statsd) do |informant|
+  ::NSA.inform_statsd($statsd) do |informant|
     informant.collect(:action_controller, :web)
     informant.collect(:active_record, :db)
     informant.collect(:active_support_cache, :cache)