Class: MongoLogsOnRoids::RuntimeSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/mongo_logs_on_roids/runtime_subscriber.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reset_runtimeObject



15
16
17
18
# File 'lib/mongo_logs_on_roids/runtime_subscriber.rb', line 15

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

.runtimeObject



11
12
13
# File 'lib/mongo_logs_on_roids/runtime_subscriber.rb', line 11

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

.runtime=(value) ⇒ Object



7
8
9
# File 'lib/mongo_logs_on_roids/runtime_subscriber.rb', line 7

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

Instance Method Details

#failed(event) ⇒ Object



28
29
30
# File 'lib/mongo_logs_on_roids/runtime_subscriber.rb', line 28

def failed(event)
  self.class.runtime += event.duration*1000
end

#started(event) ⇒ Object



22
23
24
# File 'lib/mongo_logs_on_roids/runtime_subscriber.rb', line 22

def started(event)
  # noop
end

#succeeded(event) ⇒ Object

noop



25
26
27
# File 'lib/mongo_logs_on_roids/runtime_subscriber.rb', line 25

def succeeded(event)
  self.class.runtime += event.duration*1000
end