Sha256: 39e5207a9cd0e965fe24dbbaf39f4d4848cd537d73c49a722cda5511358e5691

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

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

require_relative 'net_http/chain'
require_relative 'net_http/prepend'

DependencyDetection.defer do
  named :net_http

  depends_on do
    defined?(Net) && defined?(Net::HTTP)
  end

  executes do
    ::NewRelic::Agent.logger.info 'Installing Net:HTTP Wrappers'
    require 'new_relic/agent/http_clients/net_http_wrappers'
  end

  # Airbrake uses method chaining on Net::HTTP in versions < 10.0.2 (10.0.2 updated to prepend for Net:HTTP)
  conflicts_with_prepend do
    defined?(::Airbrake) && defined?(::Airbrake::AIRBRAKE_VERSION) && ::Gem::Version.create(::Airbrake::AIRBRAKE_VERSION) < ::Gem::Version.create('10.0.2')
  end

  conflicts_with_prepend do
    defined?(::ScoutApm)
  end

  conflicts_with_prepend do
    defined?(::Rack::MiniProfiler)
  end

  conflicts_with_prepend do
    source_location_for(Net::HTTP, "request") =~ /airbrake|profiler/i
  end

  executes do
    if use_prepend?
      prepend_instrument ::Net::HTTP, ::NewRelic::Agent::Instrumentation::NetHTTP::Prepend
    else
      chain_instrument ::NewRelic::Agent::Instrumentation::NetHTTP::Chain
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
newrelic_rpm-8.9.0 lib/new_relic/agent/instrumentation/net_http.rb
newrelic_rpm-8.8.0 lib/new_relic/agent/instrumentation/net_http.rb
newrelic_rpm-8.7.0 lib/new_relic/agent/instrumentation/net_http.rb
newrelic_rpm-8.6.0 lib/new_relic/agent/instrumentation/net_http.rb
newrelic_rpm-8.5.0 lib/new_relic/agent/instrumentation/net_http.rb
newrelic_rpm-8.4.0 lib/new_relic/agent/instrumentation/net_http.rb
newrelic_rpm-8.3.0 lib/new_relic/agent/instrumentation/net_http.rb