Sha256: b180bda2511f34992d187341cb97075ba1f0314485841388da14d99b30aef1ff

Contents?: true

Size: 1.1 KB

Versions: 29

Compression:

Stored size: 1.1 KB

Contents

module Skylight
  module Probes
    module NetHTTP
      class Probe
        def install
          Net::HTTP.class_eval do
            alias request_without_sk request

            def request(req, body = nil, &block)
              unless started?
                return request_without_sk(req, body, &block)
              end

              method = req.method

              # req['host'] also includes special handling for default ports
              host, port = req['host'] ? req['host'].split(':') : nil

              # If we're connected with a persistent socket
              host ||= self.address
              port ||= self.port

              path   = req.path
              scheme = use_ssl? ? "https" : "http"

              # Contained in the path
              query  = nil

              opts = Formatters::HTTP.build_opts(method, scheme, host, port, path, query)

              Skylight.instrument(opts) do
                request_without_sk(req, body, &block)
              end
            end
          end
        end
      end
    end

    register("Net::HTTP", "net/http", NetHTTP::Probe.new)
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
skylight-0.3.21 lib/skylight/probes/net_http.rb
skylight-0.3.20 lib/skylight/probes/net_http.rb
skylight-0.3.19 lib/skylight/probes/net_http.rb
skylight-0.3.18 lib/skylight/probes/net_http.rb
skylight-0.3.17 lib/skylight/probes/net_http.rb
skylight-0.3.14 lib/skylight/probes/net_http.rb
skylight-0.3.13 lib/skylight/probes/net_http.rb
skylight-0.3.12 lib/skylight/probes/net_http.rb
skylight-0.3.11 lib/skylight/probes/net_http.rb
skylight-0.3.10 lib/skylight/probes/net_http.rb
skylight-0.3.8 lib/skylight/probes/net_http.rb
skylight-0.3.7 lib/skylight/probes/net_http.rb
skylight-0.3.6 lib/skylight/probes/net_http.rb
skylight-0.3.3 lib/skylight/probes/net_http.rb
skylight-0.3.2 lib/skylight/probes/net_http.rb
skylight-0.3.1 lib/skylight/probes/net_http.rb
skylight-0.3.0 lib/skylight/probes/net_http.rb
skylight-0.2.7 lib/skylight/probes/net_http.rb
skylight-0.2.6 lib/skylight/probes/net_http.rb
skylight-0.3.0.rc.6 lib/skylight/probes/net_http.rb