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.5.3-java lib/appsignal/hooks/net_http.rb
appsignal-2.5.3 lib/appsignal/hooks/net_http.rb
appsignal-2.5.3.alpha.2 lib/appsignal/hooks/net_http.rb
appsignal-2.5.3.alpha.2-java lib/appsignal/hooks/net_http.rb
appsignal-2.5.3.alpha.1 lib/appsignal/hooks/net_http.rb
appsignal-2.5.3.alpha.1-java lib/appsignal/hooks/net_http.rb
appsignal-2.5.2-java lib/appsignal/hooks/net_http.rb
appsignal-2.5.2 lib/appsignal/hooks/net_http.rb
appsignal-2.5.1-java lib/appsignal/hooks/net_http.rb
appsignal-2.5.1 lib/appsignal/hooks/net_http.rb
appsignal-2.5.1.beta.1-java lib/appsignal/hooks/net_http.rb
appsignal-2.5.1.beta.1 lib/appsignal/hooks/net_http.rb
appsignal-2.5.0-java lib/appsignal/hooks/net_http.rb
appsignal-2.5.0 lib/appsignal/hooks/net_http.rb
appsignal-2.5.0.beta.1-java lib/appsignal/hooks/net_http.rb
appsignal-2.5.0.beta.1 lib/appsignal/hooks/net_http.rb
appsignal-2.5.0.alpha.1-java lib/appsignal/hooks/net_http.rb
appsignal-2.5.0.alpha.1 lib/appsignal/hooks/net_http.rb
appsignal-2.4.3 lib/appsignal/hooks/net_http.rb
appsignal-2.4.2 lib/appsignal/hooks/net_http.rb