Class: RorVsWild::Plugin::Elasticsearch

Inherits:
Object
  • Object
show all
Defined in:
lib/rorvswild/plugin/elasticsearch.rb

Class Method Summary collapse

Class Method Details

.setupObject


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rorvswild/plugin/elasticsearch.rb', line 4

def self.setup
  return if !defined?(::Elasticsearch::Transport)
  return if ::Elasticsearch::Transport::Client.method_defined?(:perform_request_without_rorvswild)

  ::Elasticsearch::Transport::Client.class_eval do
    alias_method :perform_request_without_rorvswild, :perform_request

    def perform_request(*args)
      RorVsWild::Plugin::NetHttp.ignore do
        command = {method: args[0], path: args[1], params: args[2], body: args[3]}.to_json
        RorVsWild.agent.measure_section(command, kind: "elasticsearch") do
          perform_request_without_rorvswild(*args)
        end
      end
    end
  end
end