lib/fozzie/bulk_dsl.rb in fozzie-1.0.3 vs lib/fozzie/bulk_dsl.rb in fozzie-1.1.0

- old
+ new

@@ -1,28 +1,27 @@ -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 \ No newline at end of file +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, extra = {}) + val = extra.merge({ :bucket => 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