Class: Spyke::Instrumentation::LogSubscriber

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reset_runtimeObject



12
13
14
15
# File 'lib/spyke/instrumentation/log_subscriber.rb', line 12

def self.reset_runtime
  rt, self.runtime = runtime, 0
  rt
end

.runtimeObject



8
9
10
# File 'lib/spyke/instrumentation/log_subscriber.rb', line 8

def self.runtime
  Thread.current['spyke_request_runtime'] ||= 0
end

.runtime=(value) ⇒ Object



4
5
6
# File 'lib/spyke/instrumentation/log_subscriber.rb', line 4

def self.runtime=(value)
  Thread.current['spyke_request_runtime'] = value
end

Instance Method Details

#request(event) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/spyke/instrumentation/log_subscriber.rb', line 17

def request(event)
  return unless logger.debug?
  self.class.runtime += event.duration
  name = '%s (%.1fms)' % ["Spyke", event.duration]
  details = "#{event.payload[:method].upcase} #{event.payload[:url]} [#{event.payload[:status]}]"
  debug "  #{color(name, GREEN, true)}  #{color(details, BOLD, true)}"
end