failbot 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8b0cb0e395a797b15f920bf62da3a4bc56a92545000e12f7195ac72e3df7288
4
- data.tar.gz: 68dc6a523edceecc6b15f45799cabd380927f24d934b6c876c2d7f0726c55241
3
+ metadata.gz: 53e182bf0325cad972095bfc874140de2c28b0b771070719e7aff54fb02d8fae
4
+ data.tar.gz: 8da6d5c26fcfe301e0df2edf096e2afa0e19f40e5941ae5b03e084d8435cfab0
5
5
  SHA512:
6
- metadata.gz: fa5282763cef5946b344467cc0f8a568e7b364cc682b038bff2abcc0f807a5e86de4f454e76a70dd2c17e60c017a6a13d82e34099d0297b8b5c77c5ba41dd01f
7
- data.tar.gz: cac6f6bf0d01b2266d3c3b41507a84274bfaa9f1f9bc2d1f8b2780a1bd7c3ac51f32b4dba98541b9e6f374010559afb9769f500ee8df9cf423c6cc7e3fecc014
6
+ metadata.gz: 04c21e6c698b040686e522ebe442c04b03a31c4875e904395f4e312e07cc1741e31b59f7eca22dd5475fd32a8a867c0537306f5fbf36ef44870b5337f62ef31e
7
+ data.tar.gz: e13a7e8a016abddc60e5f071cc4b46d73f3f4e42e575bd123999d68dafdfcd7b42ec1ce2e52dfa0c4a8032b5acfbfaaaf93d6dd43efaf201ab1ad30ad085bd78
@@ -46,6 +46,16 @@ module Failbot
46
46
  # prevent recursive calls to Failbot.report!
47
47
  attr_accessor :already_reporting
48
48
 
49
+ # Root directory of the project's source. Used to clean up stack traces if the exception format supports it
50
+
51
+ def source_root=(str)
52
+ @source_root = if str
53
+ File.join(str, '')
54
+ end
55
+ end
56
+
57
+ attr_reader :source_root
58
+
49
59
  # see failbot/exit_hook.rb for more on these
50
60
  @failbot_loaded = true
51
61
  @auto_install_hook = false
@@ -1,5 +1,7 @@
1
1
  module Failbot
2
2
  # A simple parser to extract structure from ruby backtraces.
3
+ #
4
+ # See https://docs.sentry.io/development/sdk-dev/event-payloads/stacktrace/ for details on what data can sent
3
5
  class Backtrace
4
6
  # Raised when a line fails parsing.
5
7
  ParseError = Class.new(StandardError)
@@ -30,27 +32,53 @@ module Failbot
30
32
  FRAME_FORMAT = /
31
33
  \A
32
34
  \s*
33
- ([^:]+ | <.*>): # file_name
35
+ ([^:]+ | <.*>): # abs_path
34
36
  (\d+) # line_number
35
37
  (?: :in \s `([^']+)')? # method
36
38
  \z
37
39
  /x
38
40
 
39
- attr_reader :file_name, :line_number, :method
41
+ attr_reader :file_name, :line_number, :method, :abs_path
40
42
 
41
43
  # Returns a Frame given backtrace component string or raises
42
44
  # ParseError if it's malformed.
43
45
  def self.parse(unparsed_line)
44
46
  match = unparsed_line.match(FRAME_FORMAT)
45
47
  if match
46
- file_name, line_number, method = match.captures
47
- new(file_name, line_number, method)
48
+ abs_path, line_number, method = match.captures
49
+
50
+ file_name = extract_file_name(abs_path)
51
+
52
+ new(abs_path, file_name, line_number, method)
48
53
  else
49
54
  raise ParseError, "unable to parse #{unparsed_line.inspect}"
50
55
  end
51
56
  end
52
57
 
53
- def initialize(file_name, line_number, method)
58
+ # Older versions of ruby don't have String#delete_prefix so for them we
59
+ # fall back to a slower implementation.
60
+ if String.new.respond_to?(:delete_prefix)
61
+ def self.extract_file_name(abs_path)
62
+ if Failbot.source_root
63
+ abs_path.delete_prefix(Failbot.source_root)
64
+ else
65
+ abs_path
66
+ end
67
+ end
68
+ else
69
+ def self.extract_file_name(abs_path)
70
+ if Failbot.source_root
71
+ abs_path.gsub(/\A#{Failbot.source_root}/, "")
72
+ else
73
+ abs_path
74
+ end
75
+ end
76
+ end
77
+
78
+ private_class_method :extract_file_name
79
+
80
+ def initialize(abs_path, file_name, line_number, method)
81
+ @abs_path = abs_path
54
82
  @file_name = file_name
55
83
  @line_number = line_number
56
84
  @method = method
@@ -47,6 +47,7 @@ module Failbot
47
47
  Backtrace.parse(e.backtrace).frames.reverse.map do |line|
48
48
  {
49
49
  "filename" => line.file_name,
50
+ "abs_path" => line.abs_path,
50
51
  "lineno" => line.line_number,
51
52
  "function" => line.method
52
53
  }
@@ -1,3 +1,3 @@
1
1
  module Failbot
2
- VERSION = "2.4.1"
2
+ VERSION = "2.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: failbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@rtomayko"