Sha256: 3bfb4112ff1030cd423c7a6c505900004da6588ad6fe2a62338d89ce720138ba

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

# encoding: utf-8

TingYun::Support::LibraryDetection.defer do

  named :net_http

  depends_on do
    defined?(Net) && defined?(Net::HTTP) && !::TingYun::Agent.config[:disable_net_http]
  end

  executes do
    ::TingYun::Agent.logger.info 'Installing Net instrumentation'
    require 'ting_yun/agent/cross_app/cross_app_tracing'
    require 'ting_yun/http/net_http_request'
    require 'ting_yun/instrumentation/support/external_error'
  end

  executes do
    class Net::HTTP
      def request_with_tingyun_trace(request, *args, &block)
        tingyun_request = TingYun::Http::NetHttpRequest.new(self, request)

        TingYun::Agent::CrossAppTracing.tl_trace_http_request(tingyun_request) do
          TingYun::Agent.disable_all_tracing do
            request_without_tingyun_trace(request, *args, &block )
          end
        end
      end

      alias :request_without_tingyun_trace :request
      alias :request :request_with_tingyun_trace


      # class << self
      #   def get_response_with_tingyun(uri_or_host, path = nil, port = nil, &block)
      #     begin
      #       get_response_without_tingyun(uri_or_host, path , port , &block)
      #     rescue => e
      #       ::TingYun::Instrumentation::Support::ExternalError.handle_error(e, "External/#{uri_or_host.to_s.gsub(/\/\z/,'').gsub('/','%2F')}/net%2Fhttp")
      #       raise e
      #     end
      #   end
      #   alias get_response_without_tingyun get_response
      #   alias get_response get_response_with_tingyun
      #
      #   def start_with_tingyun(address, *arg, &block)
      #     begin
      #       start_without_tingyun(address, *arg, &block)
      #     rescue => e
      #       # ::TingYun::Instrumentation::Support::ExternalError.handle_error(e, "External/#{address.to_s.gsub(/\/\z/,'').gsub('/','%2F')}/net%2Fhttp")
      #       raise e
      #     end
      #   end
      #   alias :start_without_tingyun :start
      #   alias :start :start_with_tingyun
      #
      # end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tingyun_rpm-3.2.0 lib/ting_yun/instrumentation/net.rb
tingyun_rpm-1.6.1 lib/ting_yun/instrumentation/net.rb
tingyun_rpm-1.5.0 lib/ting_yun/instrumentation/net.rb