dry-monitor 0.1.1 → 0.1.2

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
- SHA256:
3
- metadata.gz: 8efc7beb94cb02a20c12514ad8beea5914a069d957b48f7c089b588fce4c8bf1
4
- data.tar.gz: ad200194b170bfdfdb8f3fe473078c6b309fc73170203deb27b61b1ace4afad4
2
+ SHA1:
3
+ metadata.gz: ca2399eb8989f99e9840024b317599e731b2e357
4
+ data.tar.gz: 01e127fab50b60edcc4ac61846907341fd826e23
5
5
  SHA512:
6
- metadata.gz: bd7e41300b4ea1c908719cd69efd6e9bd357978af9c5ae71a39a38dde35c59c5f989d26208fa56763854dcd6f7b581d87782eb26baf65ea00a944f182151767e
7
- data.tar.gz: fc6c2027758916b5447648c176f1a839fa172f1f2e0561b8c471bbcdfb79f670f5dfcab1588f7cac1d46978e118f14869f297d8211a24f3fa0992f7d5a26cabb
6
+ metadata.gz: 5175053c85e8ae01f9892a3e17fe3e2c54820379cfabde8624893ff35833d7aa9c34bc3c1bf741cab7be77fd519fd6c8bc825997934b58506a3769e63d3bc669
7
+ data.tar.gz: f01dc548ac3b1f02f72d6b5c7ed875b3100e86af9d6168be33b6910c1170979675cd4634e393dc41c53bc404ec947d2e3c38a11b3ae6d0e132b91298d62900fb
@@ -1,3 +1,9 @@
1
+ # v0.1.2 2018-01-04
2
+
3
+ ### Fixed
4
+
5
+ * Rack logger no longer prevents arbitrary payload in `:error` events (solnic)
6
+
1
7
  # v0.1.1 2018-01-03
2
8
 
3
9
  ### Fixed
@@ -36,8 +36,8 @@ module Dry
36
36
  log_stop_request(env, status, time)
37
37
  end
38
38
 
39
- rack_monitor.on(:error) do |exception:|
40
- log_exception(exception)
39
+ rack_monitor.on(:error) do |event|
40
+ log_exception(event[:exception])
41
41
  end
42
42
  end
43
43
 
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Monitor
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.1.2'.freeze
4
4
  end
5
5
  end
@@ -17,13 +17,15 @@ RSpec.describe Dry::Monitor::Rack::Middleware do
17
17
  Dry::Monitor::Rack::Logger.new(Dry::Monitor::Logger.new(log_file_path))
18
18
  end
19
19
 
20
- describe '#call' do
21
- let(:env) do
22
- { 'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/hello-world', 'REMOTE_ADDR' => '0.0.0.0', 'QUERY_STRING' => query_params }
23
- end
20
+ let(:env) do
21
+ { 'REQUEST_METHOD' => 'GET',
22
+ 'PATH_INFO' => '/hello-world',
23
+ 'REMOTE_ADDR' => '0.0.0.0',
24
+ 'QUERY_STRING' => query_params }
25
+ end
24
26
 
25
- let(:query_params) do
26
- %w[
27
+ let(:query_params) do
28
+ %w[
27
29
  _csrf=123456
28
30
  password=secret
29
31
  user[password]=secret
@@ -34,8 +36,9 @@ RSpec.describe Dry::Monitor::Rack::Middleware do
34
36
  ids[]=1
35
37
  ids[]=2
36
38
  ].join('&')
37
- end
39
+ end
38
40
 
41
+ describe '#call' do
39
42
  before do
40
43
  File.open(log_file_path, 'w').close
41
44
  rack_logger.attach(middleware)
@@ -62,12 +65,34 @@ RSpec.describe Dry::Monitor::Rack::Middleware do
62
65
  captured = []
63
66
 
64
67
  middleware.on(:error) do |event|
65
- captured << event.payload
68
+ captured << event[:exception]
69
+ captured << event[:env]
66
70
  end
67
71
 
68
- middleware.instrument(:error, exception: 'oops')
72
+ exception = 'oops'
73
+ env = { 'REQUEST_METHOD' => 'GET' }
74
+
75
+ middleware.instrument(:error, exception: exception, env: env)
76
+
77
+ expect(captured).to eql([exception, env])
78
+ end
79
+ end
80
+
81
+ describe 'rack logger' do
82
+ before do
83
+ File.open(log_file_path, 'w').close
84
+ rack_logger.attach(middleware)
85
+ end
86
+
87
+ it 'logs exceptions' do
88
+ exception = double(:exception, message: 'oops', backtrace: ['/some/path.rb'])
89
+
90
+ middleware.instrument(:error, exception: exception, env: env)
91
+
92
+ log_file_content = File.read(log_file_path)
69
93
 
70
- expect(captured).to eql([exception: 'oops'])
94
+ expect(log_file_content).to include('oops')
95
+ expect(log_file_content).to include('/some/path.rb')
71
96
  end
72
97
  end
73
98
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-03 00:00:00.000000000 Z
11
+ date: 2018-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rouge
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.7.3
171
+ rubygems_version: 2.6.11
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Monitoring and instrumentation APIs