Sha256: 56efd8bb1331463cdb45392b5be5449940a78f6fa4d3c66a223ca34b3a16b554

Contents?: true

Size: 694 Bytes

Versions: 6

Compression:

Stored size: 694 Bytes

Contents

begin
  require 'statsd'
rescue LoadError
end

module Hallmonitor
  module Outputters
    class StatsdOutputter < Outputter
      def initialize(prefix, host="localhost", port=8125)
        raise "In order to use StatsdOutputter, statsd gem must be installed" unless defined?(Statsd)
        super(prefix)
        @statsd = Statsd.new(host).tap{|sd| sd.namespace = name}
      end

      def process(event)
        if(event.respond_to?(:duration))
          @statsd.timing(event.name, event.duration)
        elsif(event.respond_to?(:value))
          @statsd.gauge(event.name, event.value)
        else
          @statsd.count(event.name, event.count)
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hallmonitor-0.4.0 lib/hallmonitor/outputters/statsd_outputter.rb
hallmonitor-0.3.0 lib/hallmonitor/outputters/statsd_outputter.rb
hallmonitor-0.2.0 lib/hallmonitor/outputters/statsd_outputter.rb
hallmonitor-0.1.1 lib/hallmonitor/outputters/statsd_outputter.rb
hallmonitor-0.1.0 lib/hallmonitor/outputters/statsd_outputter.rb
hallmonitor-0.0.2 lib/hallmonitor/outputters/statsd_outputter.rb