Sha256: 6dd445e90acea1818385ab8c60dd9b86553353385f9217fde681d7a7e8a8131d

Contents?: true

Size: 923 Bytes

Versions: 7

Compression:

Stored size: 923 Bytes

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

module NewRelic::Agent::Instrumentation
  module Elasticsearch
    def self.instrument!
      to_instrument = if ::Gem::Version.create(::Elasticsearch::VERSION) <
          ::Gem::Version.create("8.0.0")
        ::Elasticsearch::Transport::Client
      else
        ::Elastic::Transport::Client
      end

      to_instrument.class_eval do
        include NewRelic::Agent::Instrumentation::Elasticsearch

        alias_method(:perform_request_without_tracing, :perform_request)
        alias_method(:perform_request, :perform_request_with_tracing)

        def perform_request(*args)
          perform_request_with_tracing(*args) do
            perform_request_without_tracing(*args)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
newrelic_rpm-9.0.0 lib/new_relic/agent/instrumentation/elasticsearch/chain.rb
newrelic_rpm-8.16.0 lib/new_relic/agent/instrumentation/elasticsearch/chain.rb
newrelic_rpm-8.15.0 lib/new_relic/agent/instrumentation/elasticsearch/chain.rb
newrelic_rpm-8.14.0 lib/new_relic/agent/instrumentation/elasticsearch/chain.rb
newrelic_rpm-8.13.1 lib/new_relic/agent/instrumentation/elasticsearch/chain.rb
newrelic_rpm-8.13.0 lib/new_relic/agent/instrumentation/elasticsearch/chain.rb
newrelic_rpm-8.12.0 lib/new_relic/agent/instrumentation/elasticsearch/chain.rb