Sha256: 8b32cd6cf2acf8b59a333ba2154af4bb0316423b6b24d5d3dc7f35ec19a71e3a

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 KB

Contents

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

DependencyDetection.defer do
  @name = :net

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

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

  executes do
    class Net::HTTP
      # Instrument outgoing HTTP requests
      #
      # If request is called when not the connection isn't started, request
      # will call back into itself (via a start block).
      #
      # Don't tracing until the inner call then to avoid double-counting.
      def request_with_newrelic_trace(request, *args, &block)
        if started?
          wrapped_request = NewRelic::Agent::HTTPClients::NetHTTPRequest.new(self, request)
          NewRelic::Agent::CrossAppTracing.trace_http_request( wrapped_request ) do
            request_without_newrelic_trace( request, *args, &block )
          end
        else
          request_without_newrelic_trace( request, *args, &block )
        end
      end

      alias request_without_newrelic_trace request
      alias request request_with_newrelic_trace
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
newrelic_rpm-3.7.0.177 lib/new_relic/agent/instrumentation/net.rb
newrelic_rpm-3.7.0.174.beta lib/new_relic/agent/instrumentation/net.rb
newrelic_rpm-3.6.9.171 lib/new_relic/agent/instrumentation/net.rb
newrelic_rpm-3.6.8.168 lib/new_relic/agent/instrumentation/net.rb
newrelic_rpm-3.6.8.164 lib/new_relic/agent/instrumentation/net.rb
newrelic_rpm-3.6.7.159 lib/new_relic/agent/instrumentation/net.rb
newrelic_rpm-3.6.7.159.beta lib/new_relic/agent/instrumentation/net.rb
newrelic_rpm-3.6.7.152 lib/new_relic/agent/instrumentation/net.rb
newrelic_rpm-3.6.6.147 lib/new_relic/agent/instrumentation/net.rb
newrelic_rpm-3.6.5.130 lib/new_relic/agent/instrumentation/net.rb