Class: Metrux::Commands::Timer
- Defined in:
- lib/metrux/commands/timer.rb
Constant Summary collapse
- TIMER_MEASUREMENT_PREFIX_KEY =
'timers/'.freeze
Constants inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Metrux::Commands::Base
Instance Method Details
#execute(key, params = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/metrux/commands/timer.rb', line 6 def execute(key, params = {}) key = "#{TIMER_MEASUREMENT_PREFIX_KEY}#{key}" result, duration = if block_given? calculate_duration { yield } else [nil, params.fetch(:duration)] end write(key, format_data(duration, params), (params)) result end |