Class: IoMonitor::ActiveRecordAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- IoMonitor::ActiveRecordAdapter
- Defined in:
- lib/io_monitor/adapters/active_record_adapter.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.aggregate_result(rows:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/io_monitor/adapters/active_record_adapter.rb', line 13 def aggregate_result(rows:) return unless IoMonitor.aggregator.active? # `.flatten.join.bytesize` would look prettier, # but it makes a lot of unnecessary allocations. io_payload_size = rows.sum(0) do |row| row.sum(0) do |val| (String === val ? val : val.to_s).bytesize end end IoMonitor.aggregator.increment(kind, io_payload_size) end |
.kind ⇒ Object
9 10 11 |
# File 'lib/io_monitor/adapters/active_record_adapter.rb', line 9 def kind :active_record end |
Instance Method Details
#initialize! ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/io_monitor/adapters/active_record_adapter.rb', line 28 def initialize! ActiveSupport.on_load(:active_record) do ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(AbstractAdapterPatch) if Rails::VERSION::MAJOR >= 7 ActiveRecord::FutureResult.prepend(FutureResultPatch) end end end |