Class: Bones::RPC::Instrumentable::Log
- Inherits:
-
Object
- Object
- Bones::RPC::Instrumentable::Log
- Defined in:
- lib/bones/rpc/instrumentable/log.rb
Overview
Provides logging instrumentation for compatibility with active support notifications.
Class Method Summary collapse
-
.instrument(name, payload = {}) ⇒ Object
Instrument the log payload.
Class Method Details
.instrument(name, payload = {}) ⇒ Object
Instrument the log payload.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bones/rpc/instrumentable/log.rb', line 25 def instrument(name, payload = {}) started = Time.new begin yield if block_given? rescue Exception => e payload[:exception] = [ e.class.name, e. ] raise e ensure runtime = ("%.4fms" % (1000 * (Time.now.to_f - started.to_f))) if name == TOPIC Bones::RPC::Loggable.log_operations(payload[:prefix], payload[:ops], runtime) else Bones::RPC::Loggable.debug(payload[:prefix], payload.reject { |k,v| k == :prefix }, runtime) end end end |