Sha256: 22febe7da1b079b700b4686deea0028ed5b30594d7826261b9b52268390ff559
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require "skylight/formatters/http" module Skylight module Probes module NetHTTP module Instrumentation def request(req, *) return super if !started? || Probes::NetHTTP::Probe.disabled? 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 ||= address port ||= 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) { super } end end # Probe for instrumenting Net::HTTP requests. Works by monkeypatching the default Net::HTTP#request method. class Probe DISABLED_KEY = :__skylight_net_http_disabled def self.disable state_was = Thread.current[DISABLED_KEY] Thread.current[DISABLED_KEY] = true yield ensure Thread.current[DISABLED_KEY] = state_was end def self.disabled? !!Thread.current[DISABLED_KEY] end def install Net::HTTP.prepend(Instrumentation) end end end register(:net_http, "Net::HTTP", "net/http", NetHTTP::Probe.new) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
skylight-5.0.0.beta | lib/skylight/probes/net_http.rb |