lib/pliny/metrics.rb in pliny-0.32.0 vs lib/pliny/metrics.rb in pliny-1.0.0

- old
+ new

@@ -14,24 +14,26 @@ end counts end - def measure(*names, **opts, &block) + def measure(*inputs, &block) if block elapsed, return_value = time_elapsed(&block) end + opts = inputs.last.is_a?(Hash) ? inputs.pop : {} + measurement = if opts.has_key?(:value) opts[:value] elsif block elapsed else 0 end - measures = Hash[names.map { |n| ["#{Config.app_name}.#{n}", measurement] }] + measures = Hash[inputs.map { |n| ["#{Config.app_name}.#{n}", measurement] }] backends.each do |backend| report_and_catch { backend.report_measures(measures) } end