class RooOnRails::Statsd

Attributes

client[R]

Public Class Methods

new() click to toggle source
# File lib/roo_on_rails/statsd.rb, line 10
def initialize
  @client = defined?(::STATSD) ? ::STATSD : ::Datadog::Statsd.new(host, port, tags: tags)
end

Private Instance Methods

app_name() click to toggle source
# File lib/roo_on_rails/statsd.rb, line 40
def app_name
  ENV['STATSD_APP_NAME'] || ENV['HEROKU_APP_NAME'] || hopper_app_name || 'unknown'
end
env_name() click to toggle source
# File lib/roo_on_rails/statsd.rb, line 32
def env_name
  ENV['STATSD_ENV'] || ENV['HOPPER_ECS_CLUSTER_NAME'] || 'unknown'
end
hopper_app_name() click to toggle source
# File lib/roo_on_rails/statsd.rb, line 44
def hopper_app_name
  app_name = ENV['HOPPER_APP_NAME']
  cluster_name = ENV['HOPPER_ECS_CLUSTER_NAME']
  return unless app_name && cluster_name
  [app_name, cluster_name].join('-')
end
host() click to toggle source
# File lib/roo_on_rails/statsd.rb, line 16
def host
  ENV.fetch('STATSD_HOST', 'localhost')
end
port() click to toggle source
# File lib/roo_on_rails/statsd.rb, line 20
def port
  ENV.fetch('STATSD_PORT', 8125)
end
source_name() click to toggle source
# File lib/roo_on_rails/statsd.rb, line 36
def source_name
  ENV['DYNO'] || ENV['HOSTNAME'] || 'unknown'
end
tags() click to toggle source
# File lib/roo_on_rails/statsd.rb, line 24
def tags
  [
    "env:#{env_name}",
    "source:#{source_name}",
    "app:#{app_name}"
  ]
end