lib/instrumental/agent.rb in instrumental_agent-0.10.1 vs lib/instrumental/agent.rb in instrumental_agent-0.11.0

- old
+ new

@@ -102,13 +102,13 @@ end # Store a gauge for a metric, optionally at a specific time. # # agent.gauge('load', 1.23) - def gauge(metric, value, time = Time.now) - if valid?(metric, value, time) && - send_command("gauge", metric, value, time.to_i) + def gauge(metric, value, time = Time.now, count = 1) + if valid?(metric, value, time, count) && + send_command("gauge", metric, value, time.to_i, count.to_i) value else nil end rescue Exception => e @@ -150,13 +150,13 @@ end # Increment a metric, optionally more than one or at a specific time. # # agent.increment('users') - def increment(metric, value = 1, time = Time.now) - if valid?(metric, value, time) && - send_command("increment", metric, value, time.to_i) + def increment(metric, value = 1, time = Time.now, count = 1) + if valid?(metric, value, time, count) && + send_command("increment", metric, value, time.to_i, count.to_i) value else nil end rescue Exception => e @@ -256,10 +256,10 @@ def valid_note?(note) note !~ /[\n\r]/ end - def valid?(metric, value, time) + def valid?(metric, value, time, count) valid_metric = metric =~ /^([\d\w\-_]+\.)*[\d\w\-_]+$/i valid_value = value.to_s =~ /^-?\d+(\.\d+)?(e-\d+)?$/ return true if valid_metric && valid_value