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, in_app_pattern: nil, &backtrace_cleanup_callback) ⇒ Object
deprecated
private
Deprecated.
project_root, in_app_pattern passed from outside
-
.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.
73 74 75 |
# File 'lib/sentry/backtrace.rb', line 73 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.
60 61 62 |
# File 'lib/sentry/backtrace.rb', line 60 def self.line_cache @line_cache ||= Concurrent::Map.new end |
.parse(backtrace, project_root, app_dirs_pattern, in_app_pattern: nil, &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.
project_root, in_app_pattern passed from outside
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sentry/backtrace.rb', line 15 def self.parse(backtrace, project_root, app_dirs_pattern, in_app_pattern: nil, &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 is now passed in from StacktraceBuilder, so this regex won't be triggered # only here for backwards compat and will be deleted in_app_pattern ||= Regexp.new("^(#{project_root}/)?#{app_dirs_pattern}") 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.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/sentry/backtrace.rb', line 67 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.
89 90 91 92 93 94 95 |
# File 'lib/sentry/backtrace.rb', line 89 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.
77 78 79 |
# File 'lib/sentry/backtrace.rb', line 77 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.
81 82 83 84 85 86 87 |
# File 'lib/sentry/backtrace.rb', line 81 def to_s content = [] lines.each do |line| content << line end content.join("\n") end |