Sha256: 6071264c478edd62cf1d6ab0934b703660a210c4898f9b72863f65ac2f033178

Contents?: true

Size: 661 Bytes

Versions: 3

Compression:

Stored size: 661 Bytes

Contents

module Collectd
  # EventMachine support stuff. Included in Collectd::Plugin.
  module EmPlugin
    ##
    # Attaches additional callback and errback to deferrable to track
    # a common set of success/error rate/latency
    def track_deferrable(name, deferrable)
      attach_time = Time.now
      deferrable.callback do |*a|
        push_deferrable_values("#{name} success", attach_time)
      end
      deferrable.errback do |*a|
        push_deferrable_values("#{name} error", attach_time)
      end
    end
    def push_deferrable_values(name, attach_time)
      latency(name).gauge = Time.now - attach_time
      counter(name).count! 1
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
astro-collectd-0.0.7 lib/collectd/em_support.rb
astro-collectd-0.0.8 lib/collectd/em_support.rb
astro-collectd-0.0.9 lib/collectd/em_support.rb