Module: Taskinator::LogStats
- Defined in:
- lib/taskinator/log_stats.rb
Class Method Summary collapse
- .client ⇒ Object
- .client=(statsd_client) ⇒ Object
- .count(stat, count) ⇒ Object
- .decrement(stat) ⇒ Object
- .duration(stat, duration) ⇒ Object
- .gauge(stat, count) ⇒ Object
- .increment(stat) ⇒ Object
- .initialize_client ⇒ Object
- .timing(stat, &block) ⇒ Object
Class Method Details
.client ⇒ Object
11 12 13 |
# File 'lib/taskinator/log_stats.rb', line 11 def client defined?(@client) ? @client : initialize_client end |
.client=(statsd_client) ⇒ Object
15 16 17 |
# File 'lib/taskinator/log_stats.rb', line 15 def client=(statsd_client) @client = (statsd_client ? statsd_client : initialize_client) end |
.count(stat, count) ⇒ Object
36 37 38 |
# File 'lib/taskinator/log_stats.rb', line 36 def count(stat, count) client.count(stat, count) end |
.decrement(stat) ⇒ Object
44 45 46 |
# File 'lib/taskinator/log_stats.rb', line 44 def decrement(stat) client.decrement(stat) end |
.duration(stat, duration) ⇒ Object
19 20 21 |
# File 'lib/taskinator/log_stats.rb', line 19 def duration(stat, duration) client.timing(stat, duration * 1000) end |
.gauge(stat, count) ⇒ Object
32 33 34 |
# File 'lib/taskinator/log_stats.rb', line 32 def gauge(stat, count) client.gauge(stat, count) end |
.increment(stat) ⇒ Object
40 41 42 |
# File 'lib/taskinator/log_stats.rb', line 40 def increment(stat) client.increment(stat) end |
.initialize_client ⇒ Object
7 8 9 |
# File 'lib/taskinator/log_stats.rb', line 7 def initialize_client @client = Statsd.new() end |
.timing(stat, &block) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/taskinator/log_stats.rb', line 23 def timing(stat, &block) result = nil duration = Benchmark.realtime do result = yield end duration(stat, duration) result end |