You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
582 B

  1. # frozen_string_literal: true
  2. StatsD.prefix = 'mastodon'
  3. StatsD.default_sample_rate = 1
  4. StatsDMonitor.extend(StatsD::Instrument)
  5. StatsDMonitor.statsd_measure(:call, 'request.duration')
  6. STATSD_REQUEST_METRICS = {
  7. 'request.status.success' => 200,
  8. 'request.status.not_found' => 404,
  9. 'request.status.too_many_requests' => 429,
  10. 'request.status.internal_server_error' => 500,
  11. }.freeze
  12. STATSD_REQUEST_METRICS.each do |name, code|
  13. StatsDMonitor.statsd_count_if(:call, name) do |status, _env, _body|
  14. status.to_i == code
  15. end
  16. end