class StackifyRubyAPM::Spies::CurbEasySpy
@api private
Attributes
_apm_http_verb[RW]
Public Class Methods
http_delete(*args)
click to toggle source
# File lib/stackify_apm/spies/curb/easy.rb, line 230 def self.http_delete(*args) req = nil return http_delete_without_apm(*args) unless StackifyRubyAPM.current_transaction begin # Data configuration # @_apm_http_verb = :DELETE method = @_apm_http_verb uri = args[0].strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return http_delete_without_apm(*args) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do res = http_delete_without_apm(*args) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled ctx.update_request_body("") 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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end
http_get(*args)
click to toggle source
# File lib/stackify_apm/spies/curb/easy.rb, line 181 def self.http_get(*args) req = nil return http_get_without_apm(*args) unless StackifyRubyAPM.current_transaction begin # Data configuration # @_apm_http_verb = :GET method = @_apm_http_verb uri = args[0].strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return http_get_without_apm(*args) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do res = http_get_without_apm(*args) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled ctx.update_request_body("") 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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end
http_post(*args)
click to toggle source
# File lib/stackify_apm/spies/curb/easy.rb, line 70 def self.http_post(*args) req = nil return http_post_without_apm(*args) unless StackifyRubyAPM.current_transaction begin # Data configuration # @_apm_http_verb = :POST method = @_apm_http_verb uri = args[0].strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return http_post_without_apm(*args) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do res = http_post_without_apm(*args) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled if args.length == 2 request_body = args[1].to_s elsif args.length > 2 request_body = {} contents = args[1..-1] contents.each do |data| request_body[data.name] = data.content end request_body = request_body.to_json else request_body = "" end ctx.update_request_body(request_body) 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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end
http_put(url, data)
click to toggle source
# File lib/stackify_apm/spies/curb/easy.rb, line 132 def self.http_put(url, data) req = nil return http_put_without_apm(url, data) unless StackifyRubyAPM.current_transaction begin # Data configuration # @_apm_http_verb = :PUT method = @_apm_http_verb uri = url.strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return http_put_without_apm(url, data) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do res = http_put_without_apm(url, data) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled ctx.update_request_body(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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end
perform(*args)
click to toggle source
# File lib/stackify_apm/spies/curb/easy.rb, line 19 def self.perform(*args) req = nil return perform_without_apm(*args) unless StackifyRubyAPM.current_transaction begin # Data configuration @_apm_http_verb ||= :GET method = @_apm_http_verb uri = args[0].strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" # Builds span context # ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return perform_without_apm(*args) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do # Submits HTTP request # res = perform_without_apm(*args) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled ctx.update_request_body("") 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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end
Public Instance Methods
install()
click to toggle source
# File lib/stackify_apm/spies/curb/easy.rb, line 11 def install Curl::Easy.class_eval do singleton_class.send(:alias_method, :perform_without_apm, :perform) singleton_class.send(:alias_method, :http_head_without_apm, :http_head) singleton_class.send(:alias_method, :http_post_without_apm, :http_post) singleton_class.send(:alias_method, :http_put_without_apm, :http_put) singleton_class.send(:alias_method, :http_get_without_apm, :http_get) singleton_class.send(:alias_method, :http_delete_without_apm, :http_delete) def self.perform(*args) req = nil return perform_without_apm(*args) unless StackifyRubyAPM.current_transaction begin # Data configuration @_apm_http_verb ||= :GET method = @_apm_http_verb uri = args[0].strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" # Builds span context # ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return perform_without_apm(*args) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do # Submits HTTP request # res = perform_without_apm(*args) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled ctx.update_request_body("") 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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end def self.http_post(*args) req = nil return http_post_without_apm(*args) unless StackifyRubyAPM.current_transaction begin # Data configuration # @_apm_http_verb = :POST method = @_apm_http_verb uri = args[0].strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return http_post_without_apm(*args) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do res = http_post_without_apm(*args) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled if args.length == 2 request_body = args[1].to_s elsif args.length > 2 request_body = {} contents = args[1..-1] contents.each do |data| request_body[data.name] = data.content end request_body = request_body.to_json else request_body = "" end ctx.update_request_body(request_body) 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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end def self.http_put(url, data) req = nil return http_put_without_apm(url, data) unless StackifyRubyAPM.current_transaction begin # Data configuration # @_apm_http_verb = :PUT method = @_apm_http_verb uri = url.strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return http_put_without_apm(url, data) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do res = http_put_without_apm(url, data) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled ctx.update_request_body(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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end def self.http_get(*args) req = nil return http_get_without_apm(*args) unless StackifyRubyAPM.current_transaction begin # Data configuration # @_apm_http_verb = :GET method = @_apm_http_verb uri = args[0].strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return http_get_without_apm(*args) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do res = http_get_without_apm(*args) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled ctx.update_request_body("") 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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end def self.http_delete(*args) req = nil return http_delete_without_apm(*args) unless StackifyRubyAPM.current_transaction begin # Data configuration # @_apm_http_verb = :DELETE method = @_apm_http_verb uri = args[0].strip name = "#{method} #{uri}" type = "ext.Curb.Easy.#{method}" ctx = Span::Context.new( CATEGORY: 'Web External', SUBCATEGORY: 'Execute', URL: uri, STATUS: '', METHOD: method ) rescue Exception => e StackifyRubyAPM.agent.error "[CurbEasySpy] Error: creating span context." StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" return http_delete_without_apm(*args) end # Creates new span from HTTP result StackifyRubyAPM.span name, type, context: ctx do res = http_delete_without_apm(*args) begin status_code = res.status.sub(/^0-9/, '').to_i ctx.update_status(status_code) if StackifyRubyAPM.agent.config.prefix_enabled ctx.update_request_body("") 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 '[CurbEasySpy] Error: getting status code or updating request/response context.' StackifyRubyAPM.agent.error "[CurbEasySpy] #{e.inspect}" end res end end end end