lib/rack/insight/instrumentation/instrument.rb in rack-insight-0.5.4 vs lib/rack/insight/instrumentation/instrument.rb in rack-insight-0.5.5

- old
+ new

@@ -1,7 +1,7 @@ require 'rack/insight/instrumentation/backstage' -require 'rack/insight/logger' +require 'rack/insight/logging' module Rack::Insight module Instrumentation class Instrument MethodCall = Struct.new(:call_number, :backtrace, :file, :line, :object, :context, :kind, :method, :thread) @@ -32,13 +32,13 @@ def initialize() @start = Time.now @collectors = nil end - include Backstage + include Rack::Insight::Instrumentation::Backstage - include Logging + include Rack::Insight::Logging def run(object, context="::", kind=:instance, called_at = caller[0], method = "<unknown>", args=[], &blk) file, line, rest = called_at.split(':') call_number = backstage{ self.class.seq_number } method_call = backstage{ MethodCall.new(call_number, caller(1), file, line, object, context, kind, method, Thread::current) } @@ -60,26 +60,28 @@ ClassProbe.get_probe_chain(method_call.context) end collectors = probe_chain.inject([]) do |list, probe| probe.collectors(method_call.method) end - logger.debug do - "Probe chain for: #{method_call.context} #{method_call.kind} #{method_call.method}:\n #{collectors.map{|col| col.class.name}.join(", ")}" + if verbose(:debug) + logger.debug do + "Probe chain for: #{method_call.context} #{method_call.kind} #{method_call.method}:\n #{collectors.map{|col| col.class.name}.join(", ")}" + end end collectors end def start_event(method_call, arguments) - logger.debug{ "Starting event: #{method_call.context} #{method_call.kind} #{method_call.method}" } + logger.debug{ "Starting event: #{method_call.context} #{method_call.kind} #{method_call.method}" } if verbose(:high) collectors_for(method_call).each do |collector| collector.before_detect(method_call, arguments) end end def finish_event(method_call, arguments, start_time, result) timing = Timing.new(@start, start_time, Time.now) - logger.debug{ "Finishing event: #{method_call.context} #{method_call.kind} #{method_call.method}" } + logger.debug{ "Finishing event: #{method_call.context} #{method_call.kind} #{method_call.method}" } if verbose(:high) collectors_for(method_call).each do |collector| collector.after_detect(method_call, timing, arguments, result) end end