Module: Fozzie::Interface
Instance Method Summary collapse
-
#build(extra = {}) ⇒ Object
Registers a build for the app.
-
#built(extra = {}) ⇒ Object
Registers that the app has been built.
-
#bulk(&block) ⇒ Object
Register multiple statistics in a single call.
-
#commit(extra = {}) ⇒ Object
Registers a commit.
-
#committed(extra = {}) ⇒ Object
Registers a commit.
-
#count(stat, count, sample_rate = 1, extra = {}) ⇒ Object
Registers a count for the given stat, with an optional sample rate.
-
#decrement(stat, sample_rate = 1, extra = {}) ⇒ Object
Decrements the given stat by one, with an optional sample rate.
-
#deploy(app = nil, extra = {}) ⇒ Object
Registers a deployment for the given app.
-
#deployed(app = nil, extra = {}) ⇒ Object
Registers a deployed status for the given app.
-
#event(type, app = nil, extra = {}) ⇒ Object
Register an event of any type.
-
#gauge(stat, value, sample_rate = 1, extra = {}) ⇒ Object
Register an arbitrary value.
-
#increment(stat, sample_rate = 1, extra = {}) ⇒ Object
Increments the given stat by one, with an optional sample rate.
-
#increment_on(stat, perf, sample_rate = 1, extra = {}) ⇒ Object
Registers an increment on the result of the given boolean.
-
#time(stat, sample_rate = 1, extra = {}) ⇒ Object
Registers the time taken to complete a given block (in ms), with an optional sample rate.
-
#time_for(stat, sample_rate = 1, extra = {}, &block) ⇒ Object
Registers the time taken to complete a given block (in ms), with an optional sample rate.
-
#time_to_do(stat, sample_rate = 1, extra = {}, &block) ⇒ Object
Registers the time taken to complete a given block (in ms), with an optional sample rate.
-
#timing(stat, ms, sample_rate = 1, extra = {}) ⇒ Object
Registers a timing (in ms) for the given stat, with an optional sample rate.
Instance Method Details
#build(extra = {}) ⇒ Object
Registers a build for the app
‘Stats.build`
83 84 85 |
# File 'lib/fozzie/interface.rb', line 83 def build(extra = {}) built(extra) end |
#built(extra = {}) ⇒ Object
Registers that the app has been built
‘Stats.built`
76 77 78 |
# File 'lib/fozzie/interface.rb', line 76 def built(extra = {}) event(:build, nil, extra) end |
#bulk(&block) ⇒ Object
Register multiple statistics in a single call
‘Stats.bulk do
increment 'wat'
decrement 'wot'
end`
130 131 132 |
# File 'lib/fozzie/interface.rb', line 130 def bulk(&block) Fozzie::BulkDsl.new(&block) end |
#commit(extra = {}) ⇒ Object
Registers a commit
‘Stats.commit`
62 63 64 |
# File 'lib/fozzie/interface.rb', line 62 def commit(extra = {}) event(:commit, nil, extra) end |
#committed(extra = {}) ⇒ Object
Registers a commit
‘Stats.commit`
69 70 71 |
# File 'lib/fozzie/interface.rb', line 69 def committed(extra = {}) commit(extra) end |
#count(stat, count, sample_rate = 1, extra = {}) ⇒ Object
Registers a count for the given stat, with an optional sample rate
‘Stats.count ’wat’, 500`
24 25 26 |
# File 'lib/fozzie/interface.rb', line 24 def count(stat, count, sample_rate=1, extra = {}) send(stat, count, :count, sample_rate, extra) end |
#decrement(stat, sample_rate = 1, extra = {}) ⇒ Object
Decrements the given stat by one, with an optional sample rate
‘Stats.decrement ’wat’‘
17 18 19 |
# File 'lib/fozzie/interface.rb', line 17 def decrement(stat, sample_rate=1, extra = {}) count(stat, -1, sample_rate, extra) end |
#deploy(app = nil, extra = {}) ⇒ Object
Registers a deployment for the given app
‘Stats.deploy ’watapp’‘
97 98 99 |
# File 'lib/fozzie/interface.rb', line 97 def deploy(app = nil, extra = {}) deployed(app, extra) end |
#deployed(app = nil, extra = {}) ⇒ Object
Registers a deployed status for the given app
‘Stats.deployed ’watapp’‘
90 91 92 |
# File 'lib/fozzie/interface.rb', line 90 def deployed(app = nil, extra = {}) event(:deploy, app, extra) end |
#event(type, app = nil, extra = {}) ⇒ Object
Register an event of any type
‘Stats.event ’wat’, ‘app’‘
104 105 106 |
# File 'lib/fozzie/interface.rb', line 104 def event(type, app = nil, extra = {}) gauge(["event", type.to_s, app], Time.now.usec, 1, extra) end |
#gauge(stat, value, sample_rate = 1, extra = {}) ⇒ Object
Register an arbitrary value
‘Stats.gauge ’wat’, ‘app’‘
120 121 122 |
# File 'lib/fozzie/interface.rb', line 120 def gauge(stat, value, sample_rate = 1, extra = {}) send(stat, value, :gauge, sample_rate, extra) end |
#increment(stat, sample_rate = 1, extra = {}) ⇒ Object
Increments the given stat by one, with an optional sample rate
‘Stats.increment ’wat’‘
10 11 12 |
# File 'lib/fozzie/interface.rb', line 10 def increment(stat, sample_rate=1, extra = {}) count(stat, 1, sample_rate, extra) end |
#increment_on(stat, perf, sample_rate = 1, extra = {}) ⇒ Object
Registers an increment on the result of the given boolean
‘Stats.increment_on ’wat’, wat.random?‘
111 112 113 114 115 |
# File 'lib/fozzie/interface.rb', line 111 def increment_on(stat, perf, sample_rate=1, extra = {}) key = [stat, (perf ? "success" : "fail")] increment(key, sample_rate, extra) perf end |
#time(stat, sample_rate = 1, extra = {}) ⇒ Object
Registers the time taken to complete a given block (in ms), with an optional sample rate
‘Stats.time ’wat’ { # Do something… }‘
38 39 40 41 42 43 |
# File 'lib/fozzie/interface.rb', line 38 def time(stat, sample_rate=1, extra = {}) start = Time.now result = yield timing(stat, ((Time.now - start) * 1000).round, sample_rate, extra) result end |
#time_for(stat, sample_rate = 1, extra = {}, &block) ⇒ Object
Registers the time taken to complete a given block (in ms), with an optional sample rate
‘Stats.time_for ’wat’ { # Do something, grrr… }‘
55 56 57 |
# File 'lib/fozzie/interface.rb', line 55 def time_for(stat, sample_rate=1, extra = {}, &block) time(stat, sample_rate, extra, &block) end |
#time_to_do(stat, sample_rate = 1, extra = {}, &block) ⇒ Object
Registers the time taken to complete a given block (in ms), with an optional sample rate
‘Stats.time_to_do ’wat’ { # Do something, again… }‘
48 49 50 |
# File 'lib/fozzie/interface.rb', line 48 def time_to_do(stat, sample_rate=1, extra = {}, &block) time(stat, sample_rate, extra, &block) end |
#timing(stat, ms, sample_rate = 1, extra = {}) ⇒ Object
Registers a timing (in ms) for the given stat, with an optional sample rate
‘Stats.timing ’wat’, 500`
31 32 33 |
# File 'lib/fozzie/interface.rb', line 31 def timing(stat, ms, sample_rate=1, extra = {}) send(stat, ms, :timing, sample_rate, extra) end |