Class: Sentry::StacktraceBuilder
- Inherits:
-
Object
- Object
- Sentry::StacktraceBuilder
- Defined in:
- lib/sentry/interfaces/stacktrace_builder.rb
Instance Attribute Summary collapse
- #app_dirs_pattern ⇒ Regexp? readonly
- #backtrace_cleanup_callback ⇒ Proc? readonly
- #context_lines ⇒ Integer? readonly
- #filename_cache ⇒ FilenameCache readonly
- #linecache ⇒ LineCache readonly
- #project_root ⇒ String readonly
- #strip_backtrace_load_path ⇒ Boolean readonly
Instance Method Summary collapse
-
#build(backtrace:, &frame_callback) {|frame| ... } ⇒ StacktraceInterface
Generates a StacktraceInterface with the given backtrace.
-
#initialize(project_root:, app_dirs_pattern:, linecache:, context_lines:, backtrace_cleanup_callback: nil, strip_backtrace_load_path: true) ⇒ StacktraceBuilder
constructor
A new instance of StacktraceBuilder.
Constructor Details
#initialize(project_root:, app_dirs_pattern:, linecache:, context_lines:, backtrace_cleanup_callback: nil, strip_backtrace_load_path: true) ⇒ StacktraceBuilder
Returns a new instance of StacktraceBuilder.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 40 def initialize( project_root:, app_dirs_pattern:, linecache:, context_lines:, backtrace_cleanup_callback: nil, strip_backtrace_load_path: true ) @project_root = project_root @app_dirs_pattern = app_dirs_pattern @linecache = linecache @context_lines = context_lines @backtrace_cleanup_callback = backtrace_cleanup_callback @strip_backtrace_load_path = strip_backtrace_load_path @in_app_pattern = Regexp.new("^(#{project_root}/)?#{app_dirs_pattern}") if app_dirs_pattern @filename_cache = FilenameCache.new(project_root) end |
Instance Attribute Details
#app_dirs_pattern ⇒ Regexp? (readonly)
11 12 13 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 11 def app_dirs_pattern @app_dirs_pattern end |
#backtrace_cleanup_callback ⇒ Proc? (readonly)
20 21 22 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 20 def backtrace_cleanup_callback @backtrace_cleanup_callback end |
#context_lines ⇒ Integer? (readonly)
17 18 19 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 17 def context_lines @context_lines end |
#filename_cache ⇒ FilenameCache (readonly)
26 27 28 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 26 def filename_cache @filename_cache end |
#linecache ⇒ LineCache (readonly)
14 15 16 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 14 def linecache @linecache end |
#project_root ⇒ String (readonly)
8 9 10 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 8 def project_root @project_root end |
#strip_backtrace_load_path ⇒ Boolean (readonly)
23 24 25 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 23 def strip_backtrace_load_path @strip_backtrace_load_path end |
Instance Method Details
#build(backtrace:, &frame_callback) {|frame| ... } ⇒ StacktraceInterface
Generates a StacktraceInterface with the given backtrace. You can pass a block to customize/exclude frames:
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 73 def build(backtrace:, &frame_callback) parsed_lines = parse_backtrace_lines(backtrace) # Build frames in reverse order, skipping lines without files # Single pass instead of select + reverse + map + compact frames = [] i = parsed_lines.size - 1 while i >= 0 line = parsed_lines[i] i -= 1 next unless line.file frame = convert_parsed_line_into_frame(line) frame = frame_callback.call(frame) if frame_callback frames << frame if frame end StacktraceInterface.new(frames: frames) end |