Sha256: a9eb87f0e1e3d68fdb22282d74fc5cf53f3a2f33d2690032f3832e060dc90939

Contents?: true

Size: 694 Bytes

Versions: 1

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.guage(event.name, event.value)
        else
          @statsd.count(event.name, event.count)
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hallmonitor-0.0.1 lib/hallmonitor/outputters/statsd_outputter.rb