Class: Flexirest::Instrumentation

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.calls_madeObject



22
23
24
# File 'lib/flexirest/instrumentation.rb', line 22

def self.calls_made
  @@calls_made ||= 0
end

.calls_made=(value) ⇒ Object



18
19
20
# File 'lib/flexirest/instrumentation.rb', line 18

def self.calls_made=(value)
  @@calls_made = value
end

.resetObject



26
27
28
29
# File 'lib/flexirest/instrumentation.rb', line 26

def self.reset
  @@time_spent = 0
  @@calls_made = 0
end

.time_spentObject



14
15
16
# File 'lib/flexirest/instrumentation.rb', line 14

def self.time_spent
  @@time_spent ||= 0
end

.time_spent=(value) ⇒ Object



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

def self.time_spent=(value)
  @@time_spent = value
end

Instance Method Details

#loggerObject



31
32
33
# File 'lib/flexirest/instrumentation.rb', line 31

def logger
  Flexirest::Logger
end

#request_call(event) ⇒ Object



3
4
5
6
7
8
# File 'lib/flexirest/instrumentation.rb', line 3

def request_call(event)
  self.class.time_spent += event.duration
  self.class.calls_made += 1
  name = '%s (%.1fms)' % [Flexirest.name, event.duration]
  Flexirest::Logger.debug "  \033[1;4;32m#{name}\033[0m #{event.payload[:name]}" unless event.payload[:quiet]
end