Class: Sentry::Backtrace::Line Private
- Inherits:
-
Object
- Object
- Sentry::Backtrace::Line
- Defined in:
- lib/sentry/backtrace/line.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Handles backtrace parsing line by line
Constant Summary collapse
- RB_EXTENSION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
".rb"- RUBY_INPUT_FORMAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
regexp (optional leading X: on windows, or JRuby9000 class-prefix)
/ ^ \s* (?: [a-zA-Z]: | uri:classloader: )? ([^:]+ | <.*>): (\d+) (?: :in\s('|`)(?:([\w:]+)\#)?([^']+)')?$ /x
- JAVA_INPUT_FORMAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
/^([\w$.]+)\.([\w$]+)\(([\w$.]+):(\d+)\)$/
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
private
The file portion of the line (such as app/models/user.rb).
- #in_app_pattern ⇒ Object readonly private
-
#method ⇒ Object
readonly
private
The method of the line (such as index).
-
#module_name ⇒ Object
readonly
private
The module name (JRuby).
-
#number ⇒ Object
readonly
private
The line number portion of the line.
Class Method Summary collapse
-
.from_source_location(location, in_app_pattern = nil) ⇒ Line
private
Creates a Line from a Thread::Backtrace::Location object This is more efficient than converting to string and parsing with regex.
-
.parse(unparsed_line, in_app_pattern = nil) ⇒ Line
private
Parses a single line of a given backtrace.
Instance Method Summary collapse
- #==(other) ⇒ Object private
- #in_app ⇒ Object private
-
#initialize(file, number, method, module_name, in_app_pattern) ⇒ Line
constructor
private
A new instance of Line.
- #inspect ⇒ Object private
-
#to_s ⇒ Object
private
Reconstructs the line in a readable fashion.
Constructor Details
#initialize(file, number, method, module_name, in_app_pattern) ⇒ Line
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Line.
67 68 69 70 71 72 73 |
# File 'lib/sentry/backtrace/line.rb', line 67 def initialize(file, number, method, module_name, in_app_pattern) @file = file @module_name = module_name @number = number.to_i @method = method @in_app_pattern = in_app_pattern end |
Instance Attribute Details
#file ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The file portion of the line (such as app/models/user.rb)
20 21 22 |
# File 'lib/sentry/backtrace/line.rb', line 20 def file @file end |
#in_app_pattern ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/sentry/backtrace/line.rb', line 31 def in_app_pattern @in_app_pattern end |
#method ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The method of the line (such as index)
26 27 28 |
# File 'lib/sentry/backtrace/line.rb', line 26 def method @method end |
#module_name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The module name (JRuby)
29 30 31 |
# File 'lib/sentry/backtrace/line.rb', line 29 def module_name @module_name end |
#number ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The line number portion of the line
23 24 25 |
# File 'lib/sentry/backtrace/line.rb', line 23 def number @number end |
Class Method Details
.from_source_location(location, in_app_pattern = nil) ⇒ Line
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a Line from a Thread::Backtrace::Location object This is more efficient than converting to string and parsing with regex
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sentry/backtrace/line.rb', line 55 def self.from_source_location(location, in_app_pattern = nil) file = location.absolute_path number = location.lineno method = location.base_label label = location.label index = label.index("#") || label.index(".") module_name = label[0, index] if index new(file, number, method, module_name, in_app_pattern) end |
.parse(unparsed_line, in_app_pattern = nil) ⇒ Line
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parses a single line of a given backtrace
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sentry/backtrace/line.rb', line 36 def self.parse(unparsed_line, in_app_pattern = nil) ruby_match = unparsed_line.match(RUBY_INPUT_FORMAT) if ruby_match _, file, number, _, module_name, method = ruby_match.to_a file.sub!(/\.class$/, RB_EXTENSION) module_name = module_name else java_match = unparsed_line.match(JAVA_INPUT_FORMAT) _, module_name, method, file, number = java_match.to_a end new(file, number, method, module_name, in_app_pattern) end |
Instance Method Details
#==(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
90 91 92 |
# File 'lib/sentry/backtrace/line.rb', line 90 def ==(other) to_s == other.to_s end |
#in_app ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 78 79 80 81 82 83 |
# File 'lib/sentry/backtrace/line.rb', line 75 def in_app return false unless in_app_pattern if file =~ in_app_pattern true else false end end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
94 95 96 |
# File 'lib/sentry/backtrace/line.rb', line 94 def inspect "<Line:#{self}>" end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Reconstructs the line in a readable fashion
86 87 88 |
# File 'lib/sentry/backtrace/line.rb', line 86 def to_s "#{file}:#{number}:in `#{method}'" end |