Commit 962f0401 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

set_value and set_field stubs

parent 7e32edeb
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -100,15 +100,31 @@ The fast way: Add your event directly to the redis-based queue:

  event

=== Gauge Modifiers Methods
=== Handler Methods

call these methods from the event-handler block

  incr(gauge_name, value=1): 
    Increment the given (two-dimensional) gauge by value
    Increment the given (two-dimensional) gauge by value at the tick specified by event-time

  incr_field(gauge_name, field_name, value=1): 
    Increment the given given field on a three-dimensional gauge by value
    Increment the given field on a three-dimensional gauge by value at the tick specified by event-time

  set_value(gauge_name, value)
    Set the given (two-dimensional) to value at the tick specified by event-time (overwrite existing value)

  set_field(gauge_name, field_name, value)
    Set the given  field on a three-dimensional gauge to value at the tick specified by event-time (overwrite existing value)

e.g.

  event :user_signed_up do
    incr(:total_registrations, 1)
    incr_field(:users_per_gender, data[:gender], 1)
  end

  # example event:
  # { "_type": "user_signed_up", "gender": "male" }
  

=== Gauge Options
@@ -252,7 +268,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

== Todos

-> set_value
-> set_value / set_field
-> bars-widget
-> timeline_widget: 'compare mode': compate gauge to yesterday
-> numbers_widget: handle decreasing vals
+42 −0
Original line number Diff line number Diff line
@@ -374,6 +374,48 @@ describe "increment three-dimensional gagues" do

  end

  describe "set value on two/three-dim gauge" do

    it "should set a value on a two-dim gauge" do  
      pending "implement me!"
      gauge_key = "fnordmetrics-myns-gauge-mygauge_5463-10"    
      @redis.hset(gauge_key, "695280200", "54")
      @redis.set(gauge_key+"-695280200-sessions-count", 5)
      @redis.hget(gauge_key, "695280200").should == "54"
      create_gauge_context({
        :key => "mygauge_5463",
        :tick => 10
      }, proc{ 
        set_value(:mygauge_5463, 17)  
      }).tap do |context|      
        event = { :_time => @now, :_session_key => "mysesskey" }
        context.call(event, @redis_wrap)
      end
      @redis.hget(gauge_key, "695280200").should == "17"
    end


    it "should set a value on a two-dim gauge" do  
      pending "implement me!"
      gauge_key = "fnordmetrics-myns-gauge-mygauge_1463-10-695280200"
      @redis.zadd(gauge_key, 65, "asdasdkey")
      @redis.zscore(gauge_key, "asdasdkey").should == "65"
      create_gauge_context({
        :key => "mygauge_1463",
        :three_dimensional => true,
        :tick => 10
      }, proc{ 
        set_field(:mygauge_1463, "asdasdkey", 23)  
      }).tap do |context|      
        event = { :_time => @now, :_session_key => "mysesskey" }
        context.call(event, @redis_wrap)
      end
      @redis.zscore(gauge_key, "asdasdkey").should == "23"
    end

  end


  it "should raise an error if incr_field is called on a 2d gauge"

private