Class: StackifyRubyAPM::Spies::CurbSpy Private
- Inherits:
-
Object
- Object
- StackifyRubyAPM::Spies::CurbSpy
- Defined in:
- lib/stackify_apm/spies/curb.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #install ⇒ Object private
Instance Method Details
#install ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 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 56 57 58 59 60 61 62 63 64 |
# File 'lib/stackify_apm/spies/curb.rb', line 10 def install Curl.module_eval do singleton_class.send(:alias_method, :http_without_apm, :http) def self.http(verb, url, _post_body = nil, _put_data = nil, &block) req = nil return http_without_apm(verb, url, _post_body = nil, _put_data = nil, &block) unless StackifyRubyAPM.current_transaction begin # Data configuration # method = verb uri = url.strip name = "#{method} #{uri}" type = "ext.Curb.#{method}" ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbSpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbSpy] #{e.inspect}" return http_without_apm(verb, url, _post_body = nil, _put_data = nil, &block) end # Creates new span from HTTP result # StackifyRubyAPM.span name, type, context: ctx do # Submits HTTP request # res = http_without_apm(verb, url, _post_body = nil, _put_data = nil, &block) begin # Builds span context # status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled ctx.update_request_body(_post_body || _put_data || "") ctx.update_request_headers(res.headers || Hash.new) ctx.update_response_body(res.body || "") ctx.update_response_headers(res.proxy_headers || Hash.new) end rescue Exception => e StackifyRubyAPM.agent.error '[NetHTTPSpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[NetHTTPSpy] #{e.inspect}" end res end end end end |