class Krane::StatsD

Constants

PREFIX

Public Class Methods

client() click to toggle source
# File lib/krane/statsd.rb, line 13
def self.client
  @client ||= begin
    sink = if ::StatsD::Instrument::Environment.current.env.fetch('STATSD_ENV', nil) == 'development'
      ::StatsD::Instrument::LogSink.new(Logger.new($stderr))
    elsif (addr = ::StatsD::Instrument::Environment.current.env.fetch('STATSD_ADDR', nil))
      ::StatsD::Instrument::UDPSink.for_addr(addr)
    else
      ::StatsD::Instrument::NullSink.new
    end
    ::StatsD::Instrument::Client.new(prefix: PREFIX, sink: sink, default_sample_rate: 1.0)
  end
end
duration(start_time) click to toggle source
# File lib/krane/statsd.rb, line 9
def self.duration(start_time)
  (Time.now.utc - start_time).round(1)
end