Module: TingYun::Instrumentation::Support::ExternalError
- Included in:
- Agent::CrossAppTracing
- Defined in:
- lib/ting_yun/instrumentation/support/external_error.rb
Class Method Summary collapse
- .capture_exception(response, request) ⇒ Object
- .handle_error(e, klass) ⇒ Object
- .set_attributes(exception, klass, code) ⇒ Object
Class Method Details
.capture_exception(response, request) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/ting_yun/instrumentation/support/external_error.rb', line 16 def capture_exception(response,request) if response && response.code.to_s =~ /^[4,5][0-9][0-9]$/ && response.code.to_s!='401' e = TingYun::Support::Exception::InternalServerError.new("#{response.code}: #{response.}") klass = "External/#{request.uri.to_s.gsub(/\/\z/,'').gsub('/','%2F')}/#{request.from}" set_attributes(e, klass, response.code) TingYun::Agent.notice_error(e,:type=>:exception) end end |
.handle_error(e, klass) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ting_yun/instrumentation/support/external_error.rb', line 26 def handle_error(e,klass) case e when Errno::ECONNREFUSED set_attributes(e, klass, 902) when SocketError set_attributes(e, klass, 901) when OpenSSL::SSL::SSLError set_attributes(e, klass, 908) when Timeout::Error set_attributes(e, klass, 903) else set_attributes(e, klass, 1000) end TingYun::Agent.notice_error(e,:type=>:exception) end |
.set_attributes(exception, klass, code) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ting_yun/instrumentation/support/external_error.rb', line 43 def set_attributes(exception, klass, code) exception.instance_exec {extend TingYun::Instrumentation::Support::Variables} begin exception.tingyun_code = code exception.tingyun_klass = klass exception.tingyun_external = true trace = caller.reject! { |t| t.include?('tingyun_rpm') } trace = trace.first(20) exception.tingyun_trace = trace rescue => e TingYun::Agent.logger.warn("Failed to set attributes for : #{exception}: ", e) end end |