nadir 1.0.2 → 1.1.0

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: 2a0977a1a853e63b9ad20a765aa18acc90b08a3f60827044d02205f808329d11
4
- data.tar.gz: 006b93b16c0df54a94a97a2d1e02733848e8aec500c7491edb42ba88142fccde
3
+ metadata.gz: b477b9b8e545334e8eafd0d2f4a0753de0177c000f5011ca7852e2762ccd29d2
4
+ data.tar.gz: '0865d783c06af66785076b118d8d88865c7dead023760f9435b2030229fbeaf1'
5
5
  SHA512:
6
- metadata.gz: c8627141fa0628b10eb2a747c3256c85746f0e3d60b950dcfee997a8a5ed044427dcae471b3720ae9dc5a10f9e1fcfe56e46d4c45c80c1531ce595957dca26b2
7
- data.tar.gz: d31b15b9cd5ee955db8188aee2c1020c88d07c879ff663ea3534f8a415ad76acbf306bac941131668ac748381396cc4081efcdd41d9dfea7233c15bc418e35b0
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 (0.2.2)
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.1)
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 = ENV['NADIR_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV']
15
- @api_key = ENV['NADIR_API_KEY']
16
- @api_url = 'https://nadir.dev/api'.freeze
17
- @enabled_for = %w(production staging)
18
- @logger = Logger.new(STDOUT)
19
- @filtered_params = %i(password credit_card secret http_cookie)
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
@@ -16,9 +16,10 @@ module Nadir
16
16
  fingerprint: fingerprint,
17
17
  host: Socket.gethostname,
18
18
  pid: Process.pid,
19
- request_params: filter(@params.dig(: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
- http = Net::HTTP.new(uri.host, uri.port)
30
-
31
- http.use_ssl = true if uri.class == URI::HTTPS
32
-
33
- request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
34
- request.body = {fault: params, api_key: @api_key}.to_json
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
@@ -1,3 +1,3 @@
1
1
  module Nadir
2
- VERSION = '1.0.2'
2
+ VERSION = '1.1.0'
3
3
  end
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.2
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-03-15 00:00:00.000000000 Z
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