Skip to content

Commit

Permalink
set_value and set_field stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
asmuth committed Dec 19, 2011
1 parent 7e32ede commit 962f040
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
24 changes: 20 additions & 4 deletions readme.rdoc
Expand Up @@ -100,16 +100,32 @@ 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

Expand Down Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions spec/gauge_modifiers_spec.rb
Expand Up @@ -374,6 +374,48 @@

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
Expand Down

0 comments on commit 962f040

Please sign in to comment.