Module: Elasticsearch::Rails::Instrumentation::Publishers::SearchRequest

Defined in:
lib/elasticsearch/rails/instrumentation/publishers.rb

Overview

Wraps the ‘SearchRequest` methods to perform the instrumentation

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/elasticsearch/rails/instrumentation/publishers.rb', line 30

def self.included(base)
  base.class_eval do
    unless method_defined?(:execute_without_instrumentation!)
      alias_method :execute_without_instrumentation!, :execute!
      alias_method :execute!, :execute_with_instrumentation!
    end
  end
end

Instance Method Details

#execute_with_instrumentation!Object

Wrap ‘Search#execute!` and perform instrumentation



41
42
43
44
45
46
47
48
# File 'lib/elasticsearch/rails/instrumentation/publishers.rb', line 41

def execute_with_instrumentation!
  ActiveSupport::Notifications.instrument "search.elasticsearch",
    name:   'Search',
    klass:  (self.klass.is_a?(Elasticsearch::Model::Proxy::ClassMethodsProxy) ? self.klass.target.to_s : self.klass.to_s),
    search: self.definition do
    execute_without_instrumentation!
  end
end