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



25
26
27
# File 'lib/frenchy/instrumentation.rb', line 25

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

Instance Method Details

#request(event) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/frenchy/instrumentation.rb', line 11

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)} GET #{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



7
8
9
# File 'lib/frenchy/instrumentation.rb', line 7

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