Module: HTTPInstrumentation::Instrumentation::ExconHook
- Defined in:
- lib/http_instrumentation/instrumentation/excon_hook.rb
Overview
This module is used to instrument the excon gem.
Class Attribute Summary collapse
-
.aliased ⇒ Object
Returns the value of attribute aliased.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.aliased ⇒ Object
Returns the value of attribute aliased.
21 22 23 |
# File 'lib/http_instrumentation/instrumentation/excon_hook.rb', line 21 def aliased @aliased end |
Class Method Details
.installed? ⇒ Boolean
17 18 19 |
# File 'lib/http_instrumentation/instrumentation/excon_hook.rb', line 17 def installed? !!(defined?(::Excon::Connection) && ::Excon::Connection.include?(self)) end |
.instrument! ⇒ Object
13 14 15 |
# File 'lib/http_instrumentation/instrumentation/excon_hook.rb', line 13 def instrument! Instrumentation.instrument!(::Excon::Connection, self, :request) if defined?(::Excon::Connection) end |
Instance Method Details
#request(params = {}, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/http_instrumentation/instrumentation/excon_hook.rb', line 24 def request(params = {}, &block) HTTPInstrumentation.instrument("excon") do |payload| response = if HTTPInstrumentation::Instrumentation::ExconHook.aliased request_without_http_instrumentation(params, &block) else super end begin info = params # Merge connection defaults under the per-request params so the # request values win. if respond_to?(:connection) info = connection.merge(params) elsif respond_to?(:data) info = data.merge(params) end scheme = info[:scheme]&.downcase default_port = ((scheme == "https") ? 443 : 80) port = info[:port] query = info[:query] query = URI.encode_www_form(query) if query.is_a?(Hash) payload[:http_method] = (info[:http_method] || info[:method]) payload[:url] = "#{scheme}://#{info[:host]}#{":#{port}" unless port == default_port}#{info[:path]}#{"?#{query}" unless query.to_s.empty?}" payload[:status_code] = response.status rescue end response end end |