Sha256: d27276c3268ea4e1f9de0d729e7b3e8458a7714a3187b1f9cdbfa30b31cbd4da

Contents?: true

Size: 869 Bytes

Versions: 6

Compression:

Stored size: 869 Bytes

Contents

module FnordMetric::Enterprise

  CompatibilityHandler = proc do
    if data[:_cmd]
     cmd = data[:_cmd].to_s
    else
      FnordMetric.error("missing key: _cmd")
      next
    end

    if m = cmd.match(/^SAMPLE (.*)(delta|mean|sum)-([0-9]+) ([0-9]+)$/)
      gauge_type = m[2].to_sym
      gauge_tick = m[3].to_i
      gauge_key = :"#{m[1]}#{gauge_type}-#{gauge_tick}"
      op_value = m[4].to_i
    else
      FnordMetric.error("invalid _cmd")
      next
    end

    gauge = if namespace.gauges.has_key?(gauge_key)
      namespace.gauges[gauge_key]
    else
      namespace.opt_gauge(gauge_key,
        :flush_interval => gauge_tick,
        :average => (gauge_type == :mean),
        :zero_config => true)
    end

    case gauge_type

      when :delta, :sum
        incr gauge, op_value

      when :mean
        incr_avg gauge, op_value

    end

  end

end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
johnf-fnordmetric-1.2.10 lib/fnordmetric/enterprise/compatibility_handler.rb
fnordmetric-1.2.9 lib/fnordmetric/enterprise/compatibility_handler.rb
johnf-fnordmetric-1.2.7 lib/fnordmetric/enterprise/compatibility_handler.rb
bp-fnordmetric-1.2.7 lib/fnordmetric/enterprise/compatibility_handler.rb
fnordmetric-1.2.7 lib/fnordmetric/enterprise/compatibility_handler.rb
fnordmetric-1.2.6 lib/fnordmetric/enterprise/compatibility_handler.rb