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