Sha256: c4879ee9b1dcbcc4eae3dc9efa42948870330af5f1edfe5b956b71c8e7cc6fdb

Contents?: true

Size: 810 Bytes

Versions: 38

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

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

        Appsignal::Environment.report_enabled("net_http")
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
appsignal-2.11.1.beta.2 lib/appsignal/hooks/net_http.rb
appsignal-2.11.1.beta.2-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.0-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.0 lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.5 lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.5-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.4 lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.4-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.3 lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.3-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.2 lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.2-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.1-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.beta.1 lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.alpha.2 lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.alpha.2-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.alpha.1 lib/appsignal/hooks/net_http.rb
appsignal-2.11.0.alpha.1-java lib/appsignal/hooks/net_http.rb