class Thrift::Metrics::Middleware::Timing

Public Class Methods

instrument(name, &block) click to toggle source
   # File lib/thrift/metrics.rb
20 def instrument(name, &block)
21   t0 = Time.now
22 
23   begin
24     r = block.call
25     send_duration name, t0
26     r
27   rescue => e
28     send_duration name, t0
29     raise e
30   end
31 end
send_duration(name, t0) click to toggle source
   # File lib/thrift/metrics.rb
13 def send_duration(name, t0)
14   Metrics.client.timing(
15     "#{name}.duration",
16     ((Time.now - t0) * 1_000).to_i
17   )
18 end