Class: Sentry::Backtrace Private
- Inherits:
-
Object
- Object
- Sentry::Backtrace
- Defined in:
- lib/sentry/backtrace.rb,
lib/sentry/backtrace/line.rb
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.
Defined Under Namespace
Classes: Line
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
private
holder for an Array of Backtrace::Line instances.
Class Method Summary collapse
- .line_cache ⇒ Object private
- .parse(backtrace, project_root, app_dirs_pattern, &backtrace_cleanup_callback) ⇒ Object private
-
.source_location ⇒ Object
private
Since Sentry is mostly used in production, we don’t want to fallback to the slower implementation and adds potentially big overhead to the application.
Instance Method Summary collapse
- #==(other) ⇒ Object private
-
#initialize(lines) ⇒ Backtrace
constructor
private
A new instance of Backtrace.
- #inspect ⇒ Object private
- #to_s ⇒ Object private
Constructor Details
#initialize(lines) ⇒ Backtrace
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 Backtrace.
71 72 73 |
# File 'lib/sentry/backtrace.rb', line 71 def initialize(lines) @lines = lines end |
Instance Attribute Details
#lines ⇒ 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.
holder for an Array of Backtrace::Line instances
11 12 13 |
# File 'lib/sentry/backtrace.rb', line 11 def lines @lines end |
Class Method Details
.line_cache ⇒ 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.
58 59 60 |
# File 'lib/sentry/backtrace.rb', line 58 def self.line_cache @line_cache ||= Concurrent::Map.new end |
.parse(backtrace, project_root, app_dirs_pattern, &backtrace_cleanup_callback) ⇒ 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.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sentry/backtrace.rb', line 13 def self.parse(backtrace, project_root, app_dirs_pattern, &backtrace_cleanup_callback) ruby_lines = backtrace.is_a?(Array) ? backtrace : backtrace.split(/\n\s*/) ruby_lines = backtrace_cleanup_callback.call(ruby_lines) if backtrace_cleanup_callback in_app_pattern ||= begin Regexp.new("^(#{project_root}/)?#{app_dirs_pattern}") end lines = ruby_lines.to_a.map do |unparsed_line| Line.parse(unparsed_line, in_app_pattern) end new(lines) end |
.source_location ⇒ 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.
Since Sentry is mostly used in production, we don’t want to fallback to the slower implementation and adds potentially big overhead to the application.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/sentry/backtrace.rb', line 65 def self.source_location(&backtrace_cleaner) Thread.each_caller_location do |location| frame_key = [location.absolute_path, location.lineno] cached_value = line_cache[frame_key] next if cached_value == :skip if cached_value return cached_value else if cleaned_frame = backtrace_cleaner.(location) line = Line.from_source_location(location) line_cache[frame_key] = line return line else line_cache[frame_key] = :skip next end end end 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.
87 88 89 90 91 92 93 |
# File 'lib/sentry/backtrace.rb', line 87 def ==(other) if other.respond_to?(:lines) lines == other.lines 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.
75 76 77 |
# File 'lib/sentry/backtrace.rb', line 75 def inspect "<Backtrace: " + lines.map(&:inspect).join(", ") + ">" 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.
79 80 81 82 83 84 85 |
# File 'lib/sentry/backtrace.rb', line 79 def to_s content = [] lines.each do |line| content << line end content.join("\n") end |