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 = {}) ⇒ 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 |
# File 'lib/http_instrumentation/instrumentation/excon_hook.rb', line 24 def request(params = {}) HTTPInstrumentation.instrument("excon") do |payload| response = if HTTPInstrumentation::Instrumentation::ExconHook.aliased request_without_http_instrumentation(params) else super end begin info = params if respond_to?(:connection) info = info.merge(connection) elsif respond_to?(:data) info = info.merge(data) end scheme = info[:scheme]&.downcase default_port = ((scheme == "https") ? 443 : 80) port = info[:port] payload[:http_method] = (info[:http_method] || info[:method]) payload[:url] = "#{scheme}://#{info[:host]}#{":#{port}" unless port == default_port}#{info[:path]}#{"?#{info[:query]}" unless info[:query].to_s.empty?}" payload[:status_code] = response.status rescue end response end end |