nadir 1.1.10 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9bdde9641cdde396db5ffc757bdad54d1e3a80bd5c50a5c0bfca0bd3b9eeb0a
4
- data.tar.gz: c7f25aca2ade3a7173cf4dc71608236adc1353a94d3f2ef046e8d25b161b7a08
3
+ metadata.gz: 66b4c92813adc0bf80380dab9021dd08134d5275f8812ffc081a3a9031a92f7c
4
+ data.tar.gz: ac9557641bab08fc2414f65cf14f728dea98e9e72fca09b179483a0dd8080c48
5
5
  SHA512:
6
- metadata.gz: a0c160705a8a8a094dd3636ea26ff7563c4b6ac877dfaa354c98e758ab515a724e1ebec4a5bce87184c9897372652853e284e0f1e8bfd984f638f734bb1f7033
7
- data.tar.gz: 0d6a5cbe7eb77aa54bce15443d1a777c18599a90ea095f7075fbe55e54167186c8daec90ecde224c0b7697bd787f0f44984bd6b965844bd7ca44ce5b7f579707
6
+ metadata.gz: b70b6a27c3d51742ea5be9753b18a819026e6143dec509bea586086525e70a2487d1161b3dd765ec877f2a8b11d087a26ef7309e14d9d0d62e8c74901f0cefc3
7
+ data.tar.gz: 95094ebac3b99887365b2fc580bd1a6d1f8d1d5e74b45e4c7a14617e506a62ca67697e978f8f1691f1e2e8dee561c48a07a5ccc53ac3e0edea193afb5620df3b
@@ -9,8 +9,8 @@ module Nadir
9
9
 
10
10
  def to_params
11
11
  {
12
- class: @exception.class.name,
13
- message: @exception.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] || $PROGRAM_NAME
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(@exception.backtrace)
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, @exception.class].join('|')
84
+ checksum = [first_backtrace_line, notification_class].join('|')
54
85
 
55
86
  Digest::SHA1.hexdigest checksum
56
87
  end
@@ -29,7 +29,7 @@ module Nadir
29
29
  post.body = {fault: params, api_key: @api_key}.to_json
30
30
 
31
31
  request = Net::HTTP.new(uri.hostname, uri.port)
32
- request.use_ssl = true
32
+ # request.use_ssl = true
33
33
  response = request.start do |http|
34
34
  http.request post
35
35
  end
data/lib/nadir/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nadir
2
- VERSION = '1.1.10'
2
+ VERSION = '1.2.0'
3
3
  end
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 exception, params
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.1.10
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: 2020-04-11 00:00:00.000000000 Z
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.0.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: []