Sha256: 67c6caa571aa2c1cd79e133dcea3ef1a23d32efcccd28d926a8333cdad50c5e5

Contents?: true

Size: 558 Bytes

Versions: 3

Compression:

Stored size: 558 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

3 entries across 3 versions & 1 rubygems

Version Path
fozzie-1.0.2 lib/fozzie/bulk_dsl.rb
fozzie-1.0.1 lib/fozzie/bulk_dsl.rb
fozzie-1.0.0 lib/fozzie/bulk_dsl.rb