diff --git a/lib/searchkick.rb b/lib/searchkick.rb index 6c21e23..d3fc33e 100644 --- a/lib/searchkick.rb +++ b/lib/searchkick.rb @@ -200,7 +200,8 @@ module Searchkick end end - def self.callbacks(value = nil) + # message is private + def self.callbacks(value = nil, message: "Bulk") if block_given? previous_value = callbacks_value begin @@ -208,7 +209,7 @@ module Searchkick result = yield if callbacks_value == :bulk event = { - name: "Bulk", + name: message, count: indexer.queued_items.size } ActiveSupport::Notifications.instrument("request.searchkick", event) do diff --git a/lib/searchkick/bulk_indexer.rb b/lib/searchkick/bulk_indexer.rb index 88f1154..ef69556 100644 --- a/lib/searchkick/bulk_indexer.rb +++ b/lib/searchkick/bulk_indexer.rb @@ -106,8 +106,10 @@ module Searchkick # import in single request with retries def import_inline(index_records, delete_records, method_name:) + action = method_name ? "Update" : "Import" + name = (index_records.first || delete_records.first).searchkick_klass.name with_retries do - Searchkick.callbacks(:bulk) do + Searchkick.callbacks(:bulk, message: "#{name} #{action}") do if index_records.any? if method_name index.bulk_update(index_records, method_name) -- libgit2 0.21.0