Sha256: 963db56a190643f1424544b1742a8655b035e4225298d5f83293361f345ff606

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

module Fozzie
  class BulkDsl
    include Fozzie::Interface

    def initialize(&block)
      @metrics = []
      block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
      send_bulk
    end

    private

    # Cache the requested metrics for bulk sending
    #
    def send(stat, value, type, sample_rate = 1)
     val = { :bin => stat, :value => value, :type => type, :sample_rate => sample_rate }

     @metrics.push(val)
    end

    def send_bulk
      return if @metrics.empty?

      adapter.register(@metrics)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fozzie-1.0.3 lib/fozzie/bulk_dsl.rb