-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 7.0.5
-
Component/s: Dev Exp
-
Environment:Rails 6.0
-
Fully Compatible
The controller runtime stats integration always reports 0ms. This is due to a mixup between mongo-ruby and Rails and how they measure time.
Specifically, Rails (and ActiveSupport) assume that event.duration is in milliseconds. However, mongo-ruby produces events with .duration in seconds.
What actually happens:
Completed 200 OK in 7ms (Views: 0.1ms | MongoDB: 0.0ms | Allocations: 2345)
What should happen:
Completed 200 OK in 7ms (Views: 0.1ms | MongoDB: 1.9ms | Allocations: 2345)
Possible fixes:
1) in railties/controller_runtime.rb, change line 63:
def _completed e
Collector.runtime += e.duration * 1000
end
This simply converts inbound seconds to milliseconds so that the value is rendered properly in log_process_action() (line 44).
2) Make event.duration conform to the ActiveSupport spec by converting everything to ms. This would make it easier to add custom logging subscribers to mongo-ruby events. Presently all subscribers would have to *1000 just like the default subscriber mentioned in (1).
This is, of course, a much farther reaching change, so perhaps (1) is more appropriate, especially for a patch release.
- is caused by
-
MONGOID-4631 Log Mongoid runtime per Rails controller action
- Closed
- related to
-
MONGOID-4661 Test applications that use Mongoid
- Closed