Sha256: 095a61c9538726a6907875074647c8560b35b5526d13fb6de0e5c355b5532fdf

Contents?: true

Size: 1.13 KB

Versions: 41

Compression:

Stored size: 1.13 KB

Contents

require 'skylight/formatters/http'

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

41 entries across 41 versions & 2 rubygems

Version Path
skylight-1.0.1 lib/skylight/probes/net_http.rb
skylight-1.0.0 lib/skylight/probes/net_http.rb
skylight-0.10.6 lib/skylight/probes/net_http.rb
skylight-1.0.0.beta5 lib/skylight/probes/net_http.rb
skylight-0.10.5 lib/skylight/probes/net_http.rb
skylight-0.10.4 lib/skylight/probes/net_http.rb
skylight-1.0.0.beta4 lib/skylight/probes/net_http.rb
skylight-1.0.0.beta3 lib/skylight/probes/net_http.rb
skylight-0.10.3 lib/skylight/probes/net_http.rb
skylight-0.10.2 lib/skylight/probes/net_http.rb
skylight-1.0.0.beta2 lib/skylight/probes/net_http.rb
skylight-0.10.0 lib/skylight/probes/net_http.rb
skylight-0.9.4 lib/skylight/probes/net_http.rb
skylight-0.9.3 lib/skylight/probes/net_http.rb
skylight-0.9.2 lib/skylight/probes/net_http.rb
skylight-0.9.1 lib/skylight/probes/net_http.rb
skylight-0.9.0 lib/skylight/probes/net_http.rb
skylight-0.8.1 lib/skylight/probes/net_http.rb
skylight-0.8.0 lib/skylight/probes/net_http.rb
skylight-0.8.0.beta.3 lib/skylight/probes/net_http.rb