Class: MongoActiveInstrumentation::LogSubscriber

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ LogSubscriber

Returns a new instance of LogSubscriber.



16
17
18
19
# File 'lib/mongo_active_instrumentation/log_subscriber.rb', line 16

def initialize(options = {})
  super()
  @events = {}
end

Class Method Details

.reset_runtimeObject



11
12
13
14
# File 'lib/mongo_active_instrumentation/log_subscriber.rb', line 11

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

.runtimeObject



7
8
9
# File 'lib/mongo_active_instrumentation/log_subscriber.rb', line 7

def self.runtime
  Thread.current["mongo_runtime"] ||= 0
end

.runtime=(value) ⇒ Object



3
4
5
# File 'lib/mongo_active_instrumentation/log_subscriber.rb', line 3

def self.runtime=(value)
  Thread.current["mongo_runtime"] = value
end

Instance Method Details

#failed(event) ⇒ Object



31
32
33
34
# File 'lib/mongo_active_instrumentation/log_subscriber.rb', line 31

def failed(event)
  return unless logger.debug?
  completed event, RED
end

#started(event) ⇒ Object



21
22
23
24
# File 'lib/mongo_active_instrumentation/log_subscriber.rb', line 21

def started(event)
  return unless logger.debug?
  @events[event.request_id] = event
end

#succeeded(event) ⇒ Object



26
27
28
29
# File 'lib/mongo_active_instrumentation/log_subscriber.rb', line 26

def succeeded(event)
  return unless logger.debug?
  completed event, CYAN
end