Module: RubyRunTracer__
- Includes:
- RubyRunGlobals, RubyRunHTML__, RubyRunUtils__
- Included in:
- RubyRunInstrumentor__, RubyRunMonitor__
- Defined in:
- lib/rubyrun/rubyrun_tracer__.rb
Overview
—————————————————————#
#
(C) Copyright Rubysophic Inc. 2007-2008 #
All rights reserved. #
#
Use, duplication or disclosure of the code is not permitted #
unless licensed. #
#
Last Updated: 7/09/08 #
—————————————————————#
#
RubyRunTracer__ is the module for tracing a line of data #
in the output destination. #
#
The source of the trace can be data from forward-tracing #
or data collected from a stack trace. #
#
—————————————————————#
Constant Summary
Constants included from RubyRunHTML__
RubyRunHTML__::METHOD_TRACE_EVEN_ROW, RubyRunHTML__::METHOD_TRACE_HEADER, RubyRunHTML__::METHOD_TRACE_ODD_ROW, RubyRunHTML__::OBJ_MAP_EVEN_ROW, RubyRunHTML__::OBJ_MAP_HTML, RubyRunHTML__::OBJ_MAP_ODD_ROW, RubyRunHTML__::REQ_PERF_BREAKDOWN_HTML, RubyRunHTML__::REQ_PERF_BREAKDOWN_TABLE_EVEN, RubyRunHTML__::REQ_PERF_BREAKDOWN_TABLE_ODD, RubyRunHTML__::THREAD_STATUS_EVEN_ROW, RubyRunHTML__::THREAD_STATUS_HTML, RubyRunHTML__::THREAD_STATUS_ODD_ROW, RubyRunHTML__::THROUGHPUT_BAR_TABLE, RubyRunHTML__::THROUGHPUT_HTML, RubyRunHTML__::THROUGHPUT_LABEL_TABLE, RubyRunHTML__::TOP_SLOWEST_REQUESTS_HTML, RubyRunHTML__::TOP_SLOWEST_REQUESTS_TABLE
Constants included from RubyRunGlobals
RubyRunGlobals::RUBYRUN_ACTIVERECORD, RubyRunGlobals::RUBYRUN_CMD_EXIT, RubyRunGlobals::RUBYRUN_CMD_HARD_KILL, RubyRunGlobals::RUBYRUN_CMD_OBJECT_MAP, RubyRunGlobals::RUBYRUN_CMD_SOFT_KILL, RubyRunGlobals::RUBYRUN_CMD_STATUS, RubyRunGlobals::RUBYRUN_DIR_HASH_FILE, RubyRunGlobals::RUBYRUN_EXCLUDE_HASH_FILE, RubyRunGlobals::RUBYRUN_FIREWALL_HASH, RubyRunGlobals::RUBYRUN_HIGHLIGHT_THRESHOLD, RubyRunGlobals::RUBYRUN_INCLUDE_HASH_FILE, RubyRunGlobals::RUBYRUN_INNER_DISPATCH_HASH, RubyRunGlobals::RUBYRUN_KILL_3_STRING, RubyRunGlobals::RUBYRUN_LOG, RubyRunGlobals::RUBYRUN_MONITOR_TIMER, RubyRunGlobals::RUBYRUN_OPTS_FILE, RubyRunGlobals::RUBYRUN_OUTER_DISPATCH_HASH, RubyRunGlobals::RUBYRUN_OUTPUT_PERF_SUMMARY, RubyRunGlobals::RUBYRUN_OUTPUT_TXN_LOG, RubyRunGlobals::RUBYRUN_PREFIX, RubyRunGlobals::RUBYRUN_PREFIX_LENGTH, RubyRunGlobals::RUBYRUN_PROP_DEFAULTS, RubyRunGlobals::RUBYRUN_REPORT, RubyRunGlobals::RUBYRUN_SIGNATURE, RubyRunGlobals::RUBYRUN_THREAD_END_HASH, RubyRunGlobals::RUBYRUN_VIEW_HASH, RubyRunGlobals::RUBYRUN_WORKING_DIR
Instance Method Summary collapse
-
#back_trace_all(th_data_hash) ⇒ Object
The stack trace global hash is printed out in the rubyrun log in thread id order, also showing the top stack of all these threads before they were interrupted.
-
#enter_trace(tid, type, obj, invoker, klass, mid, *args) ⇒ Object
1.
-
#write_trace(html_content) ⇒ Object
Write a trace entry to the trace destination.
Methods included from RubyRunUtils__
#env_var_exists?, #fatal_exit, #get_caller_detail, #get_thread_id, #is_application_controller, #is_in?, #is_rails_controller?, #return_method_name
Instance Method Details
#back_trace_all(th_data_hash) ⇒ Object
The stack trace global hash is printed out in the rubyrun log in thread id order, also showing the top stack of all these threads before they were interrupted.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rubyrun/rubyrun_tracer__.rb', line 63 def back_trace_all(th_data_hash) $rubyrun_thread_dump_reporter.info "----- RubyRun Thread Dump STARTS-----" $rubyrun_thread_stack.each {|th, stack| $rubyrun_thread_dump_reporter.info thread_id = get_thread_id(th) $rubyrun_thread_dump_reporter.info "Thread ID = #{thread_id}" $rubyrun_thread_dump_reporter.info " Last line before interrupt: #{get_top_stack(th_data_hash, thread_id)}" $rubyrun_thread_dump_reporter.info " Stack trace at interrupt" stack.each {|line| $rubyrun_thread_dump_reporter.info "\t#{line}" } } $rubyrun_thread_dump_reporter.info $rubyrun_thread_dump_reporter.info "----- RubyRun Thread Dump ENDS -----" $rubyrun_thread_stack.clear end |
#enter_trace(tid, type, obj, invoker, klass, mid, *args) ⇒ Object
-
If arguments are required to trace, try using kernel inspect to print it
-
If obejct is required to trace, try using kernel inspect to print it.
Otherwise print class name, The inspect can cause recursion and blow up ruby. Rescue only delays the issue hence not used here.
-
Show the last caller and line
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rubyrun/rubyrun_tracer__.rb', line 33 def enter_trace(tid, type, obj, invoker, klass, mid, *args) @rubyrun_trace_odd_row = true if @rubyrun_trace_odd_row == nil cur_time = Time.now html_content = sprintf("#{@rubyrun_trace_odd_row ? METHOD_TRACE_ODD_ROW : METHOD_TRACE_EVEN_ROW}", "#{cur_time.strftime("%H:%M:%S")}.#{("%.3f" % cur_time.to_f).split('.')[1]} #{cur_time.strftime("%m/%d/%y")}", get_thread_id, "#{type.split(' ').reverse.first}", "#{type.split(' ').length == 3 ? '#3B9C9C' : (@rubyrun_trace_odd_row ? '#AFDCEC' : 'white')}", "#{type.split(' ').length == 1 ? '' : (type.split(' ').length == 3 ? '*'+type.split(' ').reverse[1]+'s' : type.split(' ').reverse[1]+'s')}", klass.to_s, return_method_name(mid), "#{args.each {|arg| arg.inspect} if $rubyrun_debug_args || is_in_hash?($rubyrun_adapter_hash, klass, mid)}", "#{$rubyrun_debug_obj && obj ? obj.inspect : obj.class if obj}", "#{invoker if invoker}") write_trace(html_content) @rubyrun_trace_odd_row = !@rubyrun_trace_odd_row end |
#write_trace(html_content) ⇒ Object
Write a trace entry to the trace destination
52 53 54 55 56 57 58 |
# File 'lib/rubyrun/rubyrun_tracer__.rb', line 52 def write_trace(html_content) begin $rubyrun_tracer.info(html_content) rescue Exception => e $rubyrun_logger.warn(e.to_s) end end |