module ElastomerClient::Notifications

So you want to get notifications from your Elasticsearch client? Well, you’ve come to the right place!

require 'elastomer_client/notifications'

Requiring this module will add ActiveSupport notifications to all Elasticsearch requests. To subscribe to those requests …

ActiveSupport::Notifications.subscribe('request.client.elastomer') do |name, start_time, end_time, _, payload|
  duration = end_time - start_time
  $stderr.puts '[%s] %s %s (%.3f)' % [payload[:status], payload[:index], payload[:action], duration]
end

The payload contains the following bits of information:

If you want to use your own notifications service then you will need to let ElastomerClient know by setting the ‘service` here in the Notifications module. The service should adhere to the ActiveSupport::Notifications specification.

ElastomerClient::Notifications.service = your_own_service