Method: L2Metable#monitor
- Defined in:
- lib/l2metable.rb
#monitor(subcomponent, extras = {}, &blk) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/l2metable.rb', line 26 def monitor(subcomponent, extras = {}, &blk) unless block_given? # should never enter, but logging with something obvious instead of blowing up at runtime measure(dotted(subcomponent, "MONITOR_WITHOUT_BLOCK"), 1, extras) return end start = Time.now measure(dotted(subcomponent, "start"), 1, extras) res = nil ex = nil begin res = yield rescue => e log_exception(subcomponent, e, extras) ex = e end measure(dotted(subcomponent, "time"), Time.now - start, extras) if ex raise(ex) else res end end |