Class: Skylight::Probes::NetHTTP::Probe Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/probes/net_http.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/skylight/probes/net_http.rb', line 7

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