upfluence-utils 0.12.17 → 0.12.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/upfluence/error_logger/sentry.rb +63 -7
- data/lib/upfluence/utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a02991939eed88ee0cbfa8c803c6deec097556a821af75b06917aa788d87d3d
|
|
4
|
+
data.tar.gz: e3ec0546f19eb08e2640ad19a416b6aeda969179bdaf3ccda27de34990e782b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b958e3c16fe549af0cc0609c02f7d1225bda0f4e48ebbd2ce11bc38d210cda397dd70e191c7529d74a2270b1a10f80e4482bf03955d535cbe0476a9d5e29254a
|
|
7
|
+
data.tar.gz: d2568c9e94f6d8c62cb598488f4fb0b958a5d23d5e1fdf4a06f97a3aeb6f143542bc91a79025ad071a0854b1dd70fdaee9615f4423dfe8d17e85efc03bd9acc3
|
|
@@ -6,19 +6,53 @@ module Upfluence
|
|
|
6
6
|
module ErrorLogger
|
|
7
7
|
class Sentry
|
|
8
8
|
EXCLUDED_ERRORS = (
|
|
9
|
-
::Sentry::Configuration::IGNORE_DEFAULT + [
|
|
9
|
+
::Sentry::Configuration::IGNORE_DEFAULT + [
|
|
10
|
+
'ActiveRecord::RecordNotFound',
|
|
11
|
+
'ActiveRecord::ConcurrentMigrationError'
|
|
12
|
+
]
|
|
10
13
|
)
|
|
14
|
+
|
|
15
|
+
class << self
|
|
16
|
+
def exception_name_lambda(level, name)
|
|
17
|
+
lambda do |exception|
|
|
18
|
+
level if exception.class.name.eql? name
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def exception_message_lambda(level, message)
|
|
23
|
+
downcased_message = message.downcase
|
|
24
|
+
|
|
25
|
+
lambda do |exception|
|
|
26
|
+
level if exception.message.downcase.include?(downcased_message)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
DEFAULT_LEVEL_PROCS = [
|
|
32
|
+
exception_name_lambda(:warning, 'Net::ReadTimeout'),
|
|
33
|
+
exception_name_lambda(:warning, 'EOFError'),
|
|
34
|
+
exception_name_lambda(:warning, 'ActiveRecord::QueryCanceled'),
|
|
35
|
+
exception_name_lambda(:warning, 'Timeout::Error'),
|
|
36
|
+
exception_name_lambda(:warning, 'Errno::ECONNRESET'),
|
|
37
|
+
exception_name_lambda(:warning, 'OAuth2::ConnectionError'),
|
|
38
|
+
exception_message_lambda(:warning, 'Connection reset by peer'),
|
|
39
|
+
exception_message_lambda(:warning, 'Connection refused'),
|
|
40
|
+
exception_message_lambda(:warning, 'connection refused'),
|
|
41
|
+
exception_message_lambda(:warning, 'Failed to open TCP connection'),
|
|
42
|
+
exception_message_lambda(:warning, 'Net::ReadTimeout')
|
|
43
|
+
].freeze
|
|
11
44
|
MAX_TAG_SIZE = 8 * 1024
|
|
12
45
|
|
|
13
46
|
def initialize
|
|
14
47
|
@tag_extractors = []
|
|
48
|
+
@level_procs = [*DEFAULT_LEVEL_PROCS]
|
|
15
49
|
|
|
16
50
|
::Sentry.init do |config|
|
|
17
51
|
config.send_default_pii = true
|
|
18
52
|
config.dsn = ENV.fetch('SENTRY_DSN', nil)
|
|
19
53
|
config.environment = Upfluence.env
|
|
20
54
|
config.excluded_exceptions = EXCLUDED_ERRORS
|
|
21
|
-
config.
|
|
55
|
+
config.sdk_logger = Upfluence.logger
|
|
22
56
|
config.release = "#{ENV.fetch('PROJECT_NAME', nil)}-#{ENV.fetch('SEMVER_VERSION', nil)}"
|
|
23
57
|
config.enable_tracing = false
|
|
24
58
|
config.auto_session_tracking = false
|
|
@@ -41,6 +75,8 @@ module Upfluence
|
|
|
41
75
|
event.transaction = tx_name if tx_name
|
|
42
76
|
event.extra.merge!(prepare_extra(tags))
|
|
43
77
|
|
|
78
|
+
event.level = compute_exception_level(exc)
|
|
79
|
+
|
|
44
80
|
event
|
|
45
81
|
end
|
|
46
82
|
end
|
|
@@ -50,6 +86,12 @@ module Upfluence
|
|
|
50
86
|
@tag_extractors << klass
|
|
51
87
|
end
|
|
52
88
|
|
|
89
|
+
# proc must accept an exception and return either a sentry level (:error, :warning, etc.)
|
|
90
|
+
# or nil if the exception is not matched
|
|
91
|
+
def append_level_procs(proc)
|
|
92
|
+
@level_procs << proc
|
|
93
|
+
end
|
|
94
|
+
|
|
53
95
|
def notify(error, *args)
|
|
54
96
|
::Sentry.with_scope do |scope|
|
|
55
97
|
context = args.reduce({}) do |acc, arg|
|
|
@@ -94,13 +136,13 @@ module Upfluence
|
|
|
94
136
|
|
|
95
137
|
class RackMiddleware < ::Sentry::Rack::CaptureExceptions
|
|
96
138
|
def capture_exception(exception, env)
|
|
97
|
-
if env.key?
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
139
|
+
if env.key?('sinatra.error') && Sinatra::Base.errors.keys.any? do |klass|
|
|
140
|
+
klass.is_a?(Class) && !klass.eql?(Exception) && exception.is_a?(klass)
|
|
141
|
+
end
|
|
142
|
+
return
|
|
101
143
|
end
|
|
102
144
|
|
|
103
|
-
super
|
|
145
|
+
super
|
|
104
146
|
end
|
|
105
147
|
end
|
|
106
148
|
|
|
@@ -128,6 +170,20 @@ module Upfluence
|
|
|
128
170
|
def unit_type
|
|
129
171
|
unit_name&.split('@')&.first
|
|
130
172
|
end
|
|
173
|
+
|
|
174
|
+
def compute_exception_level(exception)
|
|
175
|
+
return :error if exception.nil?
|
|
176
|
+
|
|
177
|
+
@level_procs.each do |lvp|
|
|
178
|
+
level = lvp.call(exception)
|
|
179
|
+
|
|
180
|
+
next if level.nil?
|
|
181
|
+
|
|
182
|
+
return level
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
:error
|
|
186
|
+
end
|
|
131
187
|
end
|
|
132
188
|
end
|
|
133
189
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: upfluence-utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.12.
|
|
4
|
+
version: 0.12.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Upfluence
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-12-
|
|
11
|
+
date: 2025-12-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|