class ElasticAPM::Spies::ElasticsearchSpy

@api private

def install

rubocop:disable Metrics/MethodLength
def install
  ::Elasticsearch::Transport::Client.class_eval do
    alias perform_request_without_apm perform_request
    def perform_request(method, path, *args, &block)
      name = format(NAME_FORMAT, method, path)
      statement = args[0].is_a?(String) ? args[0] : args[0].to_json
      context = Span::Context.new(statement: statement)
      ElasticAPM.span name, TYPE, context: context do
        perform_request_without_apm(method, path, *args, &block)
      end
    end
  end
end

def perform_request(method, path, *args, &block)

def perform_request(method, path, *args, &block)
  name = format(NAME_FORMAT, method, path)
  statement = args[0].is_a?(String) ? args[0] : args[0].to_json
  context = Span::Context.new(statement: statement)
  ElasticAPM.span name, TYPE, context: context do
    perform_request_without_apm(method, path, *args, &block)
  end
end