Class: Frenchy::Instrumentation::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/frenchy/instrumentation.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runtimeObject



28
29
30
# File 'lib/frenchy/instrumentation.rb', line 28

def self.runtime
  Thread.current[:frenchy_runtime] || 0.0
end

Instance Method Details

#request(event) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/frenchy/instrumentation.rb', line 14

def request(event)
  Thread.current[:frenchy_runtime] ||= 0.0
  Thread.current[:frenchy_runtime] += event.duration
  if logger.debug?
    name = "%s (%.2fms)" % [event.payload[:service].capitalize, event.duration]
    output = "  #{color(name, YELLOW, true)} #{event.payload[:method].to_s.upcase} #{event.payload[:path]}"
    if event.payload[:params].any?
      output += "?"
      output += event.payload[:params].map {|k,v| "#{k}=#{v}" }.join("&")
    end
    debug output
  end
end

#start_processing(event) ⇒ Object



10
11
12
# File 'lib/frenchy/instrumentation.rb', line 10

def start_processing(event)
  Thread.current[:frenchy_runtime] = 0.0
end