Sha256: 31bebc8a2316d0c5927ba8978fbadfba88696a68e19f54556173823aebea7ae6

Contents?: true

Size: 751 Bytes

Versions: 19

Compression:

Stored size: 751 Bytes

Contents

require 'statsd'
module Napa
  class Stats
    class << self
      def emitter=(emitter)
        @emitter = emitter
      end

      def emitter
        unless @emitter
          # Log an error if StatsD settings are not configured
          message = 'StatsD host and port not configured in environment variables, using default settings'
          Napa::Logger.logger.warn message unless ENV['STATSD_HOST'] && ENV['STATSD_PORT']

          # Create a new StatsD emitter with the service name as the namespace
          # Defaults to localhost port 8125 if env vars are nil
          @emitter = Statsd.new(ENV['STATSD_HOST'], ENV['STATSD_PORT']).tap { |sd| sd.namespace = Napa::Identity.name }
        end
        @emitter
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
napa-0.2.1 lib/napa/stats.rb
napa-0.2.0 lib/napa/stats.rb
napa-0.1.29 lib/napa/stats.rb
napa-0.1.28 lib/napa/stats.rb
napa-0.1.26 lib/napa/stats.rb
napa-0.1.25 lib/napa/stats.rb
napa-0.1.24 lib/napa/stats.rb
napa-0.1.23 lib/napa/stats.rb
napa-0.1.22 lib/napa/stats.rb
napa-0.1.21 lib/napa/stats.rb
napa-0.1.20 lib/napa/stats.rb
napa-0.1.19 lib/napa/stats.rb
napa-0.1.18 lib/napa/stats.rb
napa-0.1.17 lib/napa/stats.rb
napa-0.1.16 lib/napa/stats.rb
napa-0.1.15 lib/napa/stats.rb
napa-0.1.14 lib/napa/stats.rb
napa-0.1.12 lib/napa/stats.rb
napa-0.1.13 lib/napa/stats.rb