lib/searchkick/logging.rb in searchkick-1.5.0 vs lib/searchkick/logging.rb in searchkick-1.5.1

- old
+ new

@@ -56,36 +56,38 @@ end end end end - module SearchkickWithInstrumentation - def multi_search(searches) - event = { - name: "Multi Search", - body: searches.flat_map { |q| [q.params.except(:body).to_json, q.body.to_json] }.map { |v| "#{v}\n" }.join - } - ActiveSupport::Notifications.instrument("multi_search.searchkick", event) do - super - end - end - - def perform_items(items) - if callbacks_value == :bulk + module IndexerWithInstrumentation + def perform + if Searchkick.callbacks_value == :bulk event = { name: "Bulk", - count: items.size + count: queued_items.size } ActiveSupport::Notifications.instrument("request.searchkick", event) do super end else super end end end + module SearchkickWithInstrumentation + def multi_search(searches) + event = { + name: "Multi Search", + body: searches.flat_map { |q| [q.params.except(:body).to_json, q.body.to_json] }.map { |v| "#{v}\n" }.join + } + ActiveSupport::Notifications.instrument("multi_search.searchkick", event) do + super + end + end + end + # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/log_subscriber.rb class LogSubscriber < ActiveSupport::LogSubscriber def self.runtime=(value) Thread.current[:searchkick_runtime] = value end @@ -176,9 +178,10 @@ end end end Searchkick::Query.send(:prepend, Searchkick::QueryWithInstrumentation) Searchkick::Index.send(:prepend, Searchkick::IndexWithInstrumentation) +Searchkick::Indexer.send(:prepend, Searchkick::IndexerWithInstrumentation) Searchkick.singleton_class.send(:prepend, Searchkick::SearchkickWithInstrumentation) Searchkick::LogSubscriber.attach_to :searchkick ActiveSupport.on_load(:action_controller) do include Searchkick::ControllerRuntime end