nadir 1.1.10 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nadir/notification.rb +36 -5
- data/lib/nadir/transport/http_async.rb +1 -1
- data/lib/nadir/version.rb +1 -1
- data/lib/nadir.rb +19 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66b4c92813adc0bf80380dab9021dd08134d5275f8812ffc081a3a9031a92f7c
|
4
|
+
data.tar.gz: ac9557641bab08fc2414f65cf14f728dea98e9e72fca09b179483a0dd8080c48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b70b6a27c3d51742ea5be9753b18a819026e6143dec509bea586086525e70a2487d1161b3dd765ec877f2a8b11d087a26ef7309e14d9d0d62e8c74901f0cefc3
|
7
|
+
data.tar.gz: 95094ebac3b99887365b2fc580bd1a6d1f8d1d5e74b45e4c7a14617e506a62ca67697e978f8f1691f1e2e8dee561c48a07a5ccc53ac3e0edea193afb5620df3b
|
data/lib/nadir/notification.rb
CHANGED
@@ -9,8 +9,8 @@ module Nadir
|
|
9
9
|
|
10
10
|
def to_params
|
11
11
|
{
|
12
|
-
class:
|
13
|
-
message:
|
12
|
+
class: notification_class,
|
13
|
+
message: message,
|
14
14
|
location: location,
|
15
15
|
backtrace: backtrace.join("\n"),
|
16
16
|
environment: Nadir.config.env,
|
@@ -23,6 +23,7 @@ module Nadir
|
|
23
23
|
request_headers: @params.dig(:request, :headers),
|
24
24
|
user: @params.dig(:request, :user),
|
25
25
|
job: @params.dig(:job),
|
26
|
+
context: @params.dig(:context),
|
26
27
|
revision: revision
|
27
28
|
}
|
28
29
|
end
|
@@ -30,7 +31,29 @@ module Nadir
|
|
30
31
|
private
|
31
32
|
|
32
33
|
def location
|
33
|
-
@params[:location]
|
34
|
+
return @params[:location] if @params[:location].present?
|
35
|
+
|
36
|
+
if $PROGRAM_NAME =~ /sidekiq/
|
37
|
+
@params.dig(:job, :class) || "Background job (Sidekiq)"
|
38
|
+
else
|
39
|
+
$PROGRAM_NAME
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def notification_class
|
44
|
+
if @exception.is_a?(StandardError)
|
45
|
+
@exception.class.name
|
46
|
+
else
|
47
|
+
"Message"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def message
|
52
|
+
if @exception.is_a?(StandardError)
|
53
|
+
@exception.message
|
54
|
+
else
|
55
|
+
@exception
|
56
|
+
end
|
34
57
|
end
|
35
58
|
|
36
59
|
def backtrace
|
@@ -43,14 +66,22 @@ module Nadir
|
|
43
66
|
cleaner.add_filter { |line| line.sub(Nadir.config.root.to_s, '') }
|
44
67
|
cleaner.add_filter { |line| line.start_with?('/') ? line.sub('/', '') : line }
|
45
68
|
cleaner.add_filter { |line| line.start_with?('.') ? line.sub('.', '') : line }
|
69
|
+
cleaner.add_silencer { |line| line.include?("nadir-rb/lib") }
|
70
|
+
|
71
|
+
stacktrace =
|
72
|
+
if @exception.is_a?(StandardError)
|
73
|
+
@exception.backtrace
|
74
|
+
else
|
75
|
+
caller
|
76
|
+
end
|
46
77
|
|
47
|
-
cleaner.clean(
|
78
|
+
cleaner.clean(stacktrace)
|
48
79
|
end
|
49
80
|
end
|
50
81
|
|
51
82
|
def fingerprint
|
52
83
|
first_backtrace_line = backtrace.find { |trace| trace !~ /pry|irb/ }
|
53
|
-
checksum = [first_backtrace_line,
|
84
|
+
checksum = [first_backtrace_line, notification_class].join('|')
|
54
85
|
|
55
86
|
Digest::SHA1.hexdigest checksum
|
56
87
|
end
|
data/lib/nadir/version.rb
CHANGED
data/lib/nadir.rb
CHANGED
@@ -22,7 +22,7 @@ module Nadir
|
|
22
22
|
def notify(exception, params = {})
|
23
23
|
return false unless config.validate
|
24
24
|
|
25
|
-
notification = Notification.new
|
25
|
+
notification = Notification.new(exception, process_params(params))
|
26
26
|
|
27
27
|
transport.deliver notification.to_params
|
28
28
|
|
@@ -33,6 +33,24 @@ module Nadir
|
|
33
33
|
false
|
34
34
|
end
|
35
35
|
|
36
|
+
def process_params(params)
|
37
|
+
ctx = Thread.current[:nadir_context]
|
38
|
+
|
39
|
+
if ctx
|
40
|
+
params[:job] = ctx.delete(:job) if ctx[:job]
|
41
|
+
params[:context] = ctx if ctx
|
42
|
+
end
|
43
|
+
|
44
|
+
params
|
45
|
+
end
|
46
|
+
|
47
|
+
def with_context(payload)
|
48
|
+
Thread.current[:nadir_context] = payload
|
49
|
+
yield
|
50
|
+
ensure
|
51
|
+
Thread.current[:nadir_context] = nil
|
52
|
+
end
|
53
|
+
|
36
54
|
private
|
37
55
|
|
38
56
|
def transport
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nadir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georgi Mitrev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -113,7 +113,7 @@ homepage: https://github.com/gmitrev/nadir-rb
|
|
113
113
|
licenses:
|
114
114
|
- MIT
|
115
115
|
metadata: {}
|
116
|
-
post_install_message:
|
116
|
+
post_install_message:
|
117
117
|
rdoc_options: []
|
118
118
|
require_paths:
|
119
119
|
- lib
|
@@ -128,8 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
132
|
-
signing_key:
|
131
|
+
rubygems_version: 3.3.26
|
132
|
+
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Ruby library for Nadir
|
135
135
|
test_files: []
|