nadir 1.0.2 → 1.1.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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/nadir/config.rb +7 -10
- data/lib/nadir/notification.rb +4 -12
- data/lib/nadir/plugins/sidekiq.rb +14 -0
- data/lib/nadir/transport/http_async.rb +8 -9
- data/lib/nadir/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b477b9b8e545334e8eafd0d2f4a0753de0177c000f5011ca7852e2762ccd29d2
|
|
4
|
+
data.tar.gz: '0865d783c06af66785076b118d8d88865c7dead023760f9435b2030229fbeaf1'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7dc6246246797ccb33e9dad2293c1ac2278f363b6bbb1ef360087bfa6fed05aa177fdfb6a9e8eb1cc47f74963cbf46308658d073e7bcbb6c8049456032f40089
|
|
7
|
+
data.tar.gz: d0be6415f97b7157543ef52cd0cdff50a415c912222cd23738c2886a25247f59014159b64f391b6ef8098d07d75f125f529c76c910004dcf13a2cde91e942082
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
nadir (
|
|
4
|
+
nadir (1.1.0)
|
|
5
5
|
commander (~> 4.4)
|
|
6
6
|
concurrent-ruby (~> 1.0)
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ GEM
|
|
|
12
12
|
highline (~> 2.0.0)
|
|
13
13
|
concurrent-ruby (1.1.5)
|
|
14
14
|
diff-lcs (1.3)
|
|
15
|
-
highline (2.0.
|
|
15
|
+
highline (2.0.2)
|
|
16
16
|
rake (10.5.0)
|
|
17
17
|
rspec (3.8.0)
|
|
18
18
|
rspec-core (~> 3.8.0)
|
data/lib/nadir/config.rb
CHANGED
|
@@ -7,16 +7,15 @@ module Nadir
|
|
|
7
7
|
:env,
|
|
8
8
|
:logger,
|
|
9
9
|
:root,
|
|
10
|
-
:enabled_for
|
|
11
|
-
:filtered_params
|
|
10
|
+
:enabled_for
|
|
12
11
|
|
|
13
12
|
def initialize
|
|
14
|
-
@env
|
|
15
|
-
@api_key
|
|
16
|
-
@api_url
|
|
17
|
-
@enabled_for
|
|
18
|
-
|
|
19
|
-
@
|
|
13
|
+
@env = ENV['NADIR_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV']
|
|
14
|
+
@api_key = ENV['NADIR_API_KEY']
|
|
15
|
+
@api_url = 'https://nadir.dev/api'.freeze
|
|
16
|
+
@enabled_for = %w(production staging)
|
|
17
|
+
|
|
18
|
+
@logger = Logger.new(STDOUT)
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
def validate
|
|
@@ -46,8 +45,6 @@ module Nadir
|
|
|
46
45
|
@api_key = file_config['api_key'] if file_config['api_key']
|
|
47
46
|
@api_url = file_config['api_url'] if file_config['api_url']
|
|
48
47
|
@enabled_for = file_config['enabled_for'] if file_config['enabled_for']
|
|
49
|
-
rescue => e
|
|
50
|
-
@logger.warn "Unable to load Nadir configuration. Please ensure that the file 'config/nadir.yml' exists and contains your API key."
|
|
51
48
|
end
|
|
52
49
|
end
|
|
53
50
|
end
|
data/lib/nadir/notification.rb
CHANGED
|
@@ -16,9 +16,10 @@ module Nadir
|
|
|
16
16
|
fingerprint: fingerprint,
|
|
17
17
|
host: Socket.gethostname,
|
|
18
18
|
pid: Process.pid,
|
|
19
|
-
request_params:
|
|
20
|
-
request_headers: filter(@params.dig(:request, :headers)),
|
|
19
|
+
request_params: @params.dig(:request, :params),
|
|
21
20
|
request_remote_ip: @params.dig(:request, :remote_ip),
|
|
21
|
+
request_headers: @params.dig(:request, :headers),
|
|
22
|
+
job: @params.dig(:job)
|
|
22
23
|
}
|
|
23
24
|
end
|
|
24
25
|
|
|
@@ -50,15 +51,6 @@ module Nadir
|
|
|
50
51
|
def gem_paths
|
|
51
52
|
@gem_paths ||= Gem.path | [Gem.default_dir]
|
|
52
53
|
end
|
|
53
|
-
|
|
54
|
-
def filter(params)
|
|
55
|
-
params_filter.filter params
|
|
56
|
-
rescue
|
|
57
|
-
params
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def params_filter
|
|
61
|
-
@params_filter ||= ActionDispatch::Http::ParameterFilter.new(Nadir.config.filtered_params || [])
|
|
62
|
-
end
|
|
63
54
|
end
|
|
64
55
|
end
|
|
56
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Nadir
|
|
2
|
+
class Sidekiq
|
|
3
|
+
def self.notify(exception, context)
|
|
4
|
+
job_params = context[:job].slice('class', 'args', 'retry_count', 'queue', 'jid')
|
|
5
|
+
location = context[:job]['class']
|
|
6
|
+
|
|
7
|
+
Nadir.notify exception, job: job_params, location: location
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
::Sidekiq.configure_server do |config|
|
|
13
|
+
config.error_handlers << Proc.new { |ex,ctx_hash| Nadir::Sidekiq.notify(ex, ctx_hash) }
|
|
14
|
+
end
|
|
@@ -25,15 +25,14 @@ module Nadir
|
|
|
25
25
|
def deliver(params)
|
|
26
26
|
self.class.thread_pool.post do
|
|
27
27
|
uri = URI("#{@api_url}/faults")
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
http.request request
|
|
28
|
+
post = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
|
29
|
+
post.body = {fault: params, api_key: @api_key}.to_json
|
|
30
|
+
|
|
31
|
+
request = Net::HTTP.new(uri.hostname, uri.port)
|
|
32
|
+
request.use_ssl = true
|
|
33
|
+
response = request.start do |http|
|
|
34
|
+
http.request post
|
|
35
|
+
end
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
end
|
data/lib/nadir/version.rb
CHANGED
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.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Georgi Mitrev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -104,6 +104,7 @@ files:
|
|
|
104
104
|
- lib/nadir/middleware/rack.rb
|
|
105
105
|
- lib/nadir/notification.rb
|
|
106
106
|
- lib/nadir/plugins/rails.rb
|
|
107
|
+
- lib/nadir/plugins/sidekiq.rb
|
|
107
108
|
- lib/nadir/transport/http_async.rb
|
|
108
109
|
- lib/nadir/version.rb
|
|
109
110
|
- nadir.gemspec
|