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
- #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.
-
#metrics_code_location(unparsed_line) ⇒ Hash
Get the code location hash for a single line for where metrics where added.
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.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 35 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 end |
Instance Attribute Details
#app_dirs_pattern ⇒ Regexp? (readonly)
9 10 11 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 9 def app_dirs_pattern @app_dirs_pattern end |
#backtrace_cleanup_callback ⇒ Proc? (readonly)
18 19 20 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 18 def backtrace_cleanup_callback @backtrace_cleanup_callback end |
#context_lines ⇒ Integer? (readonly)
15 16 17 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 15 def context_lines @context_lines end |
#linecache ⇒ LineCache (readonly)
12 13 14 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 12 def linecache @linecache end |
#project_root ⇒ String (readonly)
6 7 8 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 6 def project_root @project_root end |
#strip_backtrace_load_path ⇒ Boolean (readonly)
21 22 23 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 21 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:
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 66 def build(backtrace:, &frame_callback) parsed_lines = parse_backtrace_lines(backtrace).select(&:file) frames = parsed_lines.reverse.map do |line| frame = convert_parsed_line_into_frame(line) frame = frame_callback.call(frame) if frame_callback frame end.compact StacktraceInterface.new(frames: frames) end |
#metrics_code_location(unparsed_line) ⇒ Hash
Get the code location hash for a single line for where metrics where added.
80 81 82 83 84 |
# File 'lib/sentry/interfaces/stacktrace_builder.rb', line 80 def metrics_code_location(unparsed_line) parsed_line = Backtrace::Line.parse(unparsed_line) frame = convert_parsed_line_into_frame(parsed_line) frame.to_hash.reject { |k, _| %i[project_root in_app].include?(k) } end |