statsd.rb 613 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. if ENV['STATSD_ADDR'].present?
  3. host, port = ENV['STATSD_ADDR'].split(':')
  4. begin
  5. statsd = Statsd.new(host, port)
  6. statsd.namespace = ENV.fetch('STATSD_NAMESPACE') { ['Mastodon', Rails.env].join('.') }
  7. NSA.inform_statsd(statsd) do |informant|
  8. informant.collect(:action_controller, :web)
  9. informant.collect(:active_record, :db)
  10. informant.collect(:active_support_cache, :cache)
  11. informant.collect(:sidekiq, :sidekiq)
  12. end
  13. rescue
  14. Rails.logger.warn("statsd address #{ENV['STATSD_ADDR']} not reachable, proceeding without statsd")
  15. end
  16. end