Class: Mongoid::Railties::ControllerRuntime::Collector
- Inherits:
-
Object
- Object
- Mongoid::Railties::ControllerRuntime::Collector
- Defined in:
- lib/mongoid/railties/controller_runtime.rb
Overview
The Collector of MongoDB runtime metric, that subscribes to Mongo driver command monitoring. Stores the value within a thread-local variable to provide correct accounting when an application issues MongoDB operations from background threads.
Constant Summary collapse
- VARIABLE_NAME =
"Mongoid.controller_runtime".freeze
Class Method Summary collapse
Instance Method Summary collapse
- #_completed(e) ⇒ Object (also: #succeeded, #failed)
- #started(_) ⇒ Object
Class Method Details
.reset_runtime ⇒ Object
76 77 78 79 80 |
# File 'lib/mongoid/railties/controller_runtime.rb', line 76 def self.reset_runtime to_now = runtime self.runtime = 0 to_now end |
.runtime ⇒ Object
68 69 70 |
# File 'lib/mongoid/railties/controller_runtime.rb', line 68 def self.runtime Thread.current[VARIABLE_NAME] ||= 0 end |
.runtime=(value) ⇒ Object
72 73 74 |
# File 'lib/mongoid/railties/controller_runtime.rb', line 72 def self.runtime= value Thread.current[VARIABLE_NAME] = value end |
Instance Method Details
#_completed(e) ⇒ Object Also known as: succeeded, failed
62 63 64 |
# File 'lib/mongoid/railties/controller_runtime.rb', line 62 def _completed e Collector.runtime += e.duration end |
#started(_) ⇒ Object
60 |
# File 'lib/mongoid/railties/controller_runtime.rb', line 60 def started _; end |