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.10-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.10 lib/appsignal/hooks/net_http.rb
appsignal-2.11.9-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.9 lib/appsignal/hooks/net_http.rb
appsignal-2.11.8-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.8 lib/appsignal/hooks/net_http.rb
appsignal-2.11.7 lib/appsignal/hooks/net_http.rb
appsignal-2.11.7-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.6 lib/appsignal/hooks/net_http.rb
appsignal-2.11.6-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.5-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.5 lib/appsignal/hooks/net_http.rb
appsignal-2.11.4-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.4 lib/appsignal/hooks/net_http.rb
appsignal-2.11.3-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.3 lib/appsignal/hooks/net_http.rb
appsignal-2.11.2-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.2 lib/appsignal/hooks/net_http.rb
appsignal-2.11.1-java lib/appsignal/hooks/net_http.rb
appsignal-2.11.1 lib/appsignal/hooks/net_http.rb