Class: Mongo::Rails::Instrumentation::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Mongo::Rails::Instrumentation::LogSubscriber
- Defined in:
- lib/mongo/rails/instrumentation/log_subscriber.rb
Constant Summary collapse
- RUNTIME_KEY =
name + "#runtime"
- COUNT_KEY =
name + "#count"
Class Method Summary collapse
- .count ⇒ Object
- .count=(value) ⇒ Object
- .reset_runtime ⇒ Object
- .runtime ⇒ Object
- .runtime=(value) ⇒ Object
Instance Method Summary collapse
Class Method Details
.count ⇒ Object
19 20 21 |
# File 'lib/mongo/rails/instrumentation/log_subscriber.rb', line 19 def self.count Thread.current[COUNT_KEY] ||= 0 end |
.count=(value) ⇒ Object
15 16 17 |
# File 'lib/mongo/rails/instrumentation/log_subscriber.rb', line 15 def self.count=(value) Thread.current[COUNT_KEY] = value end |
.reset_runtime ⇒ Object
23 24 25 26 |
# File 'lib/mongo/rails/instrumentation/log_subscriber.rb', line 23 def self.reset_runtime rt, self.runtime, self.count = runtime, 0, 0 rt end |
.runtime ⇒ Object
11 12 13 |
# File 'lib/mongo/rails/instrumentation/log_subscriber.rb', line 11 def self.runtime Thread.current[RUNTIME_KEY] ||= 0 end |
.runtime=(value) ⇒ Object
7 8 9 |
# File 'lib/mongo/rails/instrumentation/log_subscriber.rb', line 7 def self.runtime=(value) Thread.current[RUNTIME_KEY] = value end |
Instance Method Details
#mongo(event) ⇒ Object
28 29 30 31 |
# File 'lib/mongo/rails/instrumentation/log_subscriber.rb', line 28 def mongo(event) self.class.runtime += event.duration self.class.count += 1 end |