Sha256: 45ea5abb0f3b91f77786d1046549e69e96313c9dd89b6aac1b16d27732ab2179

Contents?: true

Size: 720 Bytes

Versions: 38

Compression:

Stored size: 720 Bytes

Contents

require "net/http"

module Appsignal
  class Hooks
    # @api private
    class NetHttpHook < Appsignal::Hooks::Hook
      register :net_http

      def dependencies_present?
        Appsignal.config && Appsignal.config[:instrument_net_http]
      end

      def install
        Net::HTTP.class_eval do
          alias request_without_appsignal request

          def request(request, body = nil, &block)
            Appsignal.instrument(
              "request.net_http",
              "#{request.method} #{use_ssl? ? "https" : "http"}://#{request["host"] || address}"
            ) do
              request_without_appsignal(request, body, &block)
            end
          end
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
appsignal-2.4.1 lib/appsignal/hooks/net_http.rb
appsignal-2.4.0 lib/appsignal/hooks/net_http.rb
appsignal-2.4.0.alpha.1 lib/appsignal/hooks/net_http.rb
appsignal-2.3.7 lib/appsignal/hooks/net_http.rb
appsignal-2.3.6 lib/appsignal/hooks/net_http.rb
appsignal-2.3.6.beta.1 lib/appsignal/hooks/net_http.rb
appsignal-2.3.4 lib/appsignal/hooks/net_http.rb
appsignal-2.3.3 lib/appsignal/hooks/net_http.rb
appsignal-2.3.3.beta.1 lib/appsignal/hooks/net_http.rb
appsignal-2.3.2 lib/appsignal/hooks/net_http.rb
appsignal-2.3.1 lib/appsignal/hooks/net_http.rb
appsignal-2.3.0 lib/appsignal/hooks/net_http.rb
appsignal-2.3.0.beta.3 lib/appsignal/hooks/net_http.rb
appsignal-2.3.0.beta.2 lib/appsignal/hooks/net_http.rb
appsignal-2.3.0.beta.1 lib/appsignal/hooks/net_http.rb
appsignal-2.2.1 lib/appsignal/hooks/net_http.rb
appsignal-2.2.0 lib/appsignal/hooks/net_http.rb
appsignal-2.2.0.beta.1 lib/appsignal/hooks/net_http.rb