mastodon/config/initializers/statsd.rb
Tim Rogers 17f69c0002
Some checks failed
Ruby Linting / lint (push) Waiting to run
Test one step migrations / pre_job (push) Waiting to run
Test one step migrations / test (14-alpine) (push) Blocked by required conditions
Test one step migrations / test (15-alpine) (push) Blocked by required conditions
Test two step migrations / pre_job (push) Waiting to run
Test two step migrations / test (14-alpine) (push) Blocked by required conditions
Test two step migrations / test (15-alpine) (push) Blocked by required conditions
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (1, .ruby-version) (push) Blocked by required conditions
Ruby Testing / test (1, 3.0) (push) Blocked by required conditions
Ruby Testing / test (1, 3.1) (push) Blocked by required conditions
Ruby Testing / test (2, .ruby-version) (push) Blocked by required conditions
Ruby Testing / test (2, 3.0) (push) Blocked by required conditions
Ruby Testing / test (2, 3.1) (push) Blocked by required conditions
Ruby Testing / test (3, .ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3, 3.0) (push) Blocked by required conditions
Ruby Testing / test (3, 3.1) (push) Blocked by required conditions
Ruby Testing / test (4, .ruby-version) (push) Blocked by required conditions
Ruby Testing / test (4, 3.0) (push) Blocked by required conditions
Ruby Testing / test (4, 3.1) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.0) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.1) (push) Blocked by required conditions
Ruby Testing / Testing search (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Testing search (3.0) (push) Blocked by required conditions
Ruby Testing / Testing search (3.1) (push) Blocked by required conditions
Bundler Audit / security (push) Has been cancelled
CSS Linting / lint (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
JavaScript Linting / lint (push) Has been cancelled
JSON Linting / lint (push) Has been cancelled
Markdown Linting / lint (push) Has been cancelled
YML Linting / lint (push) Has been cancelled
JavaScript Testing / test (push) Has been cancelled
Added check for STATSD_ADDR setting to emit a warning and proceed rather than crashing if the address is unreachable (#30691)
2024-07-02 15:08:24 +02:00

20 lines
648 B
Ruby

# frozen_string_literal: true
if ENV['STATSD_ADDR'].present?
host, port = ENV['STATSD_ADDR'].split(':')
begin
statsd = Statsd.new(host, port)
statsd.namespace = ENV.fetch('STATSD_NAMESPACE') { ['Mastodon', Rails.env].join('.') }
NSA.inform_statsd(statsd) do |informant|
informant.collect(:action_controller, :web)
informant.collect(:active_record, :db)
informant.collect(:active_support_cache, :cache)
informant.collect(:sidekiq, :sidekiq) if ENV['STATSD_SIDEKIQ'] == 'true'
end
rescue
Rails.logger.warn("statsd address #{ENV['STATSD_ADDR']} not reachable, proceeding without statsd")
end
end