rollbar 1.2.10 → 1.2.11

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
  SHA1:
3
- metadata.gz: 8fe0625e1b83ab34a865d3b6a98052126d9229e1
4
- data.tar.gz: 8dc7faf2db9193997ceae0b41946a854b4b4ec80
3
+ metadata.gz: 933cce1a042ee31e447197924df32209b62743df
4
+ data.tar.gz: 93018fc7e8419165e4b337d43511ea65bcff4637
5
5
  SHA512:
6
- metadata.gz: df09cf158a09200135d4c3237f76dcf444000f4d3d5f8b32dbf2ebc5e7a836afbc6f04c2ee67fd36d2dc10039887566574f511a51411fb55e277eaee74b38a28
7
- data.tar.gz: 37d0a58dae25f5a9f7230a548a2b0c1bc55b8bb7e4e472c86075561681bd963ac2c9d3424300d548928da88e08b78b1a5017e6eba20b5417b7e98201865a7aa9
6
+ metadata.gz: 0d4548ff4e1c0fafbdf5a4c21a4897345c38ec94ff742f1a80d26cd6efcd0f062151597be620c20d070c4f735820ef11e442fe1bf4d8d39a022dc7b44c71e67b
7
+ data.tar.gz: 37612d8022dfd5a395b2e663fb111b943be5aac57fb9ba5101059bce7fe72c15294325403439bd34d5f137ba533bc14e532ce6d985c3412e15eba00dbeaba983
data/.travis.yml CHANGED
@@ -15,6 +15,9 @@ rvm:
15
15
  - jruby-19mode
16
16
  - jruby-head
17
17
  - rbx
18
+ env:
19
+ - SKIP_DUMMY_ROLLBAR=true
20
+ - SKIP_DUMMY_ROLLBAR=false
18
21
  matrix:
19
22
  allow_failures:
20
23
  - rvm: ruby-head
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.2.11
4
+
5
+ New features:
6
+
7
+ - Improved truncation algorithm, so that more kinds of large payloads will be successfully brought below the 128kb limit and successfully reported. See [#185](https://github.com/rollbar/rollbar-gem/pull/185)
8
+
9
+ Bug fixes:
10
+
11
+ - Fix issue where using Rollbar outside of a web process was prone to errors being silently ignored. See [#183](https://github.com/rollbar/rollbar-gem/issues/183)
12
+
13
+
3
14
  ## 1.2.10
4
15
 
5
16
  Bug fixes:
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rollbar notifier for Ruby [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v1.2.10)](https://travis-ci.org/rollbar/rollbar-gem/branches)
1
+ # Rollbar notifier for Ruby [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v1.2.11)](https://travis-ci.org/rollbar/rollbar-gem/branches)
2
2
 
3
3
  <!-- RemoveNext -->
4
4
  Ruby gem for reporting exceptions, errors, and log messages to [Rollbar](https://rollbar.com).
@@ -9,7 +9,7 @@ Ruby gem for reporting exceptions, errors, and log messages to [Rollbar](https:/
9
9
 
10
10
  Add this line to your application's Gemfile:
11
11
 
12
- gem 'rollbar', '~> 1.2.10'
12
+ gem 'rollbar', '~> 1.2.11'
13
13
 
14
14
  And then execute:
15
15
 
data/lib/rollbar.rb CHANGED
@@ -19,13 +19,13 @@ require 'rollbar/util'
19
19
  require 'rollbar/railtie' if defined?(Rails)
20
20
  require 'rollbar/delay/girl_friday'
21
21
  require 'rollbar/delay/thread'
22
+ require 'rollbar/truncation'
22
23
 
23
24
  unless ''.respond_to? :encode
24
25
  require 'iconv'
25
26
  end
26
27
 
27
28
  module Rollbar
28
- MAX_PAYLOAD_SIZE = 128 * 1024 #128kb
29
29
  ATTACHMENT_CLASSES = %w[
30
30
  ActionDispatch::Http::UploadedFile
31
31
  Rack::Multipart::UploadedFile
@@ -599,31 +599,15 @@ module Rollbar
599
599
  end
600
600
 
601
601
  def dump_payload(payload)
602
- result = MultiJson.dump(payload)
603
-
604
- # Try to truncate strings in the payload a few times if the payload is too big
605
- original_size = result.bytesize
606
- if original_size > MAX_PAYLOAD_SIZE
607
- thresholds = [1024, 512, 256]
608
- thresholds.each_with_index do |threshold, i|
609
- new_payload = payload.clone
610
-
611
- truncate_payload(new_payload, threshold)
612
-
613
- result = MultiJson.dump(new_payload)
614
-
615
- if result.bytesize <= MAX_PAYLOAD_SIZE
616
- break
617
- elsif i == thresholds.length - 1
618
- final_size = result.bytesize
619
- send_failsafe("Could not send payload due to it being too large after truncating attempts. Original size: #{original_size} Final size: #{final_size}", nil)
620
- log_error "[Rollbar] Payload too large to be sent: #{MultiJson.dump(payload)}"
621
- return
622
- end
623
- end
624
- end
602
+ result = Truncation.truncate(payload)
603
+ return result unless Truncation.truncate?(result)
625
604
 
626
- result
605
+ original_size = MultiJson.dump(payload).bytesize
606
+ final_size = result.bytesize
607
+ send_failsafe("Could not send payload due to it being too large after truncating attempts. Original size: #{original_size} Final size: #{final_size}", nil)
608
+ log_error "[Rollbar] Payload too large to be sent: #{MultiJson.dump(payload)}"
609
+
610
+ nil
627
611
  end
628
612
 
629
613
  ## Logging
@@ -667,12 +651,16 @@ module Rollbar
667
651
  # This monkey patch is always needed in order
668
652
  # to use Rollbar.scoped
669
653
  require 'rollbar/core_ext/thread'
654
+
655
+ reset_notifier!
670
656
  end
671
657
 
672
658
  def reconfigure
673
659
  @configuration = Configuration.new
674
660
  @configuration.enabled = true
675
661
  yield(configuration)
662
+
663
+ reset_notifier!
676
664
  end
677
665
 
678
666
  def unconfigure
@@ -0,0 +1,30 @@
1
+ require 'rollbar/util'
2
+ require 'rollbar/truncation/mixin'
3
+ require 'rollbar/truncation/raw_strategy'
4
+ require 'rollbar/truncation/frames_strategy'
5
+ require 'rollbar/truncation/strings_strategy'
6
+ require 'rollbar/truncation/min_body_strategy'
7
+
8
+ module Rollbar
9
+ module Truncation
10
+ extend ::Rollbar::Truncation::Mixin
11
+
12
+ MAX_PAYLOAD_SIZE = 128 * 1024 # 128kb
13
+ STRATEGIES = [RawStrategy,
14
+ FramesStrategy,
15
+ StringsStrategy,
16
+ MinBodyStrategy
17
+ ]
18
+
19
+ def self.truncate(payload)
20
+ result = nil
21
+
22
+ STRATEGIES.each do |strategy|
23
+ result = strategy.call(payload)
24
+ break unless truncate?(result)
25
+ end
26
+
27
+ result
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,44 @@
1
+ require 'rollbar/truncation/mixin'
2
+
3
+ module Rollbar
4
+ module Truncation
5
+ class FramesStrategy
6
+ include ::Rollbar::Truncation::Mixin
7
+
8
+ def self.call(payload)
9
+ new.call(payload)
10
+ end
11
+
12
+ def call(payload)
13
+ new_payload = payload.clone
14
+ body = new_payload['data'][:body]
15
+
16
+ if body[:trace_chain]
17
+ truncate_trace_chain(body)
18
+ else
19
+ truncate_trace(body)
20
+ end
21
+
22
+ dump(new_payload)
23
+ end
24
+
25
+ def truncate_trace(body)
26
+ trace_data = body[:trace]
27
+ frames = trace_data[:frames]
28
+ trace_data[:frames] = select_frames(frames)
29
+
30
+ body[:trace][:frames] = select_frames(body[:trace][:frames])
31
+ end
32
+
33
+ def truncate_trace_chain(body)
34
+ chain = body[:trace_chain]
35
+
36
+ body[:trace_chain] = chain.map do |trace_data|
37
+ frames = trace_data[:frames]
38
+ trace_data[:frames] = select_frames(frames)
39
+ trace_data
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,37 @@
1
+ require 'rollbar/truncation/mixin'
2
+
3
+ module Rollbar
4
+ module Truncation
5
+ class MinBodyStrategy
6
+ include ::Rollbar::Truncation::Mixin
7
+
8
+ def self.call(payload)
9
+ new.call(payload)
10
+ end
11
+
12
+ def call(payload)
13
+ new_payload = payload.clone
14
+ body = new_payload['data'][:body]
15
+
16
+ if body[:trace_chain]
17
+ body[:trace_chain] = body[:trace_chain].map do |trace_data|
18
+ truncate_trace_data(trace_data)
19
+ end
20
+ else
21
+ body[:trace] = truncate_trace_data(body[:trace])
22
+ end
23
+
24
+
25
+ dump(new_payload)
26
+ end
27
+
28
+ def truncate_trace_data(trace_data)
29
+ trace_data[:exception].delete(:description)
30
+ trace_data[:exception][:message] = trace_data[:exception][:message][0, 255]
31
+ trace_data[:frames] = select_frames(trace_data[:frames], 1)
32
+
33
+ trace_data
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ require 'multi_json'
2
+
3
+ module Rollbar
4
+ module Truncation
5
+ module Mixin
6
+ def dump(payload)
7
+ MultiJson.dump(payload)
8
+ end
9
+
10
+ def truncate?(result)
11
+ result.bytesize > MAX_PAYLOAD_SIZE
12
+ end
13
+
14
+ def select_frames(frames, range = 150)
15
+ return frames unless frames.count > range * 2
16
+
17
+ frames[0, range] + frames[-range, range]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ require 'rollbar/truncation/mixin'
2
+
3
+ module Rollbar
4
+ module Truncation
5
+ class RawStrategy
6
+ include ::Rollbar::Truncation::Mixin
7
+
8
+ def self.call(payload)
9
+ new.call(payload)
10
+ end
11
+
12
+ def call(payload)
13
+ dump(payload)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,42 @@
1
+ require 'rollbar/util'
2
+ require 'rollbar/truncation/mixin'
3
+
4
+ module Rollbar
5
+ module Truncation
6
+ class StringsStrategy
7
+ include ::Rollbar::Truncation::Mixin
8
+
9
+ STRING_THRESHOLDS = [1024, 512, 256]
10
+
11
+ def self.call(payload)
12
+ new.call(payload)
13
+ end
14
+
15
+ def call(payload)
16
+ result = nil
17
+ new_payload = payload.clone
18
+
19
+ STRING_THRESHOLDS.each do |threshold|
20
+ truncate_proc = truncate_strings_proc(threshold)
21
+
22
+ ::Rollbar::Util.iterate_and_update(new_payload, truncate_proc)
23
+ result = dump(new_payload)
24
+
25
+ break unless truncate?(result)
26
+ end
27
+
28
+ result
29
+ end
30
+
31
+ def truncate_strings_proc(threshold)
32
+ proc do |value|
33
+ if value.is_a?(String) && value.bytesize > threshold
34
+ Rollbar::Util.truncate(value, threshold)
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "1.2.10"
2
+ VERSION = "1.2.11"
3
3
  end
@@ -19,4 +19,4 @@ Rollbar.configure do |config|
19
19
  # Valid levels: 'critical', 'error', 'warning', 'info', 'debug', 'ignore'
20
20
  # 'ignore' will cause the exception to not be reported at all.
21
21
  # config.exception_level_filters.merge!('MyCriticalException' => 'critical')
22
- end unless ENV['SKIP_DUMMY_ROLLBAR']
22
+ end unless ENV['SKIP_DUMMY_ROLLBAR'] == "true"
@@ -0,0 +1,275 @@
1
+ {
2
+ "body": {
3
+ "trace": {
4
+ "frames": [
5
+ {
6
+ "method": "main",
7
+ "lineno": 832,
8
+ "filename": "kernel/loader.rb"
9
+ },
10
+ {
11
+ "method": "epilogue",
12
+ "lineno": 720,
13
+ "filename": "kernel/loader.rb"
14
+ },
15
+ {
16
+ "method": "run_at_exits",
17
+ "lineno": 695,
18
+ "filename": "kernel/loader.rb"
19
+ },
20
+ {
21
+ "method": "call",
22
+ "lineno": 20,
23
+ "filename": "kernel/bootstrap/proc.rb"
24
+ },
25
+ {
26
+ "method": "autorun",
27
+ "lineno": 17,
28
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb"
29
+ },
30
+ {
31
+ "method": "run",
32
+ "lineno": 103,
33
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb"
34
+ },
35
+ {
36
+ "method": "run",
37
+ "lineno": 21,
38
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb"
39
+ },
40
+ {
41
+ "method": "report",
42
+ "lineno": 58,
43
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/reporter.rb"
44
+ },
45
+ {
46
+ "method": "run",
47
+ "lineno": 24,
48
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb"
49
+ },
50
+ {
51
+ "method": "map",
52
+ "lineno": 97,
53
+ "filename": "kernel/bootstrap/array.rb"
54
+ },
55
+ {
56
+ "method": "run",
57
+ "lineno": 24,
58
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb"
59
+ },
60
+ {
61
+ "method": "run",
62
+ "lineno": 497,
63
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb"
64
+ },
65
+ {
66
+ "method": "map",
67
+ "lineno": 97,
68
+ "filename": "kernel/bootstrap/array.rb"
69
+ },
70
+ {
71
+ "method": "run",
72
+ "lineno": 497,
73
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb"
74
+ },
75
+ {
76
+ "method": "run",
77
+ "lineno": 496,
78
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb"
79
+ },
80
+ {
81
+ "method": "run_examples",
82
+ "lineno": 511,
83
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb"
84
+ },
85
+ {
86
+ "method": "map",
87
+ "lineno": 97,
88
+ "filename": "kernel/bootstrap/array.rb"
89
+ },
90
+ {
91
+ "method": "run_examples",
92
+ "lineno": 515,
93
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb"
94
+ },
95
+ {
96
+ "method": "run",
97
+ "lineno": 113,
98
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/example.rb"
99
+ },
100
+ {
101
+ "method": "with_around_each_hooks",
102
+ "lineno": 248,
103
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/example.rb"
104
+ },
105
+ {
106
+ "method": "run",
107
+ "lineno": 116,
108
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/example.rb"
109
+ },
110
+ {
111
+ "method": "instance_eval_with_args",
112
+ "lineno": 16,
113
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-core-2.99.2/lib/rspec/core/extensions/instance_eval_with_args.rb"
114
+ },
115
+ {
116
+ "method": "instance_exec",
117
+ "lineno": 101,
118
+ "filename": "kernel/common/eval.rb"
119
+ },
120
+ {
121
+ "method": "__script__",
122
+ "lineno": 15,
123
+ "filename": "/home/travis/build/rollbar/rollbar-gem/spec/requests/home_spec.rb"
124
+ },
125
+ {
126
+ "method": "to",
127
+ "lineno": 117,
128
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-expectations-2.99.2/lib/rspec/expectations/expectation_target.rb"
129
+ },
130
+ {
131
+ "method": "to",
132
+ "lineno": 59,
133
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-expectations-2.99.2/lib/rspec/expectations/expectation_target.rb"
134
+ },
135
+ {
136
+ "method": "handle_matcher",
137
+ "lineno": 24,
138
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-expectations-2.99.2/lib/rspec/expectations/handler.rb"
139
+ },
140
+ {
141
+ "method": "matches?",
142
+ "lineno": 42,
143
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rspec-expectations-2.99.2/lib/rspec/matchers/built_in/raise_error.rb"
144
+ },
145
+ {
146
+ "method": "call",
147
+ "lineno": 20,
148
+ "filename": "kernel/bootstrap/proc.rb"
149
+ },
150
+ {
151
+ "method": "__script__",
152
+ "lineno": 15,
153
+ "filename": "/home/travis/build/rollbar/rollbar-gem/spec/requests/home_spec.rb"
154
+ },
155
+ {
156
+ "method": "__script__",
157
+ "lineno": 333,
158
+ "filename": "/home/travis/.rvm/gems/rbx/gems/actionpack-3.2.17/lib/action_dispatch/testing/integration.rb"
159
+ },
160
+ {
161
+ "method": "get",
162
+ "lineno": 33,
163
+ "filename": "/home/travis/.rvm/gems/rbx/gems/actionpack-3.2.17/lib/action_dispatch/testing/integration.rb"
164
+ },
165
+ {
166
+ "method": "process",
167
+ "lineno": 299,
168
+ "filename": "/home/travis/.rvm/gems/rbx/gems/actionpack-3.2.17/lib/action_dispatch/testing/integration.rb"
169
+ },
170
+ {
171
+ "method": "request",
172
+ "lineno": 122,
173
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rack-test-0.6.2/lib/rack/test.rb"
174
+ },
175
+ {
176
+ "method": "env_for (env_for_with_rollbar)",
177
+ "lineno": 8,
178
+ "filename": "/home/travis/build/rollbar/rollbar-gem/lib/rollbar/middleware/rack/test_session.rb"
179
+ },
180
+ {
181
+ "method": "env_for_without_rollbar (env_for)",
182
+ "lineno": 220,
183
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rack-test-0.6.2/lib/rack/test.rb"
184
+ },
185
+ {
186
+ "method": "set_cookie",
187
+ "lineno": 24,
188
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rack-test-0.6.2/lib/rack/mock_session.rb"
189
+ },
190
+ {
191
+ "method": "merge",
192
+ "lineno": 132,
193
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rack-test-0.6.2/lib/rack/test/cookie_jar.rb"
194
+ },
195
+ {
196
+ "method": "each",
197
+ "lineno": 76,
198
+ "filename": "kernel/bootstrap/array.rb"
199
+ },
200
+ {
201
+ "method": "merge",
202
+ "lineno": 133,
203
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rack-test-0.6.2/lib/rack/test/cookie_jar.rb"
204
+ },
205
+ {
206
+ "method": "initialize",
207
+ "lineno": 21,
208
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rack-test-0.6.2/lib/rack/test/cookie_jar.rb"
209
+ },
210
+ {
211
+ "method": "parse_query",
212
+ "lineno": 70,
213
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rack-1.4.5/lib/rack/utils.rb"
214
+ },
215
+ {
216
+ "method": "each",
217
+ "lineno": 76,
218
+ "filename": "kernel/bootstrap/array.rb"
219
+ },
220
+ {
221
+ "method": "parse_query",
222
+ "lineno": 72,
223
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rack-1.4.5/lib/rack/utils.rb"
224
+ },
225
+ {
226
+ "method": "map",
227
+ "lineno": 97,
228
+ "filename": "kernel/bootstrap/array.rb"
229
+ },
230
+ {
231
+ "method": "call (__yield__)",
232
+ "lineno": 172,
233
+ "filename": "kernel/common/proc.rb"
234
+ },
235
+ {
236
+ "method": "call",
237
+ "lineno": 71,
238
+ "filename": "kernel/common/method.rb"
239
+ },
240
+ {
241
+ "method": "unescape",
242
+ "lineno": 41,
243
+ "filename": "/home/travis/.rvm/gems/rbx/gems/rack-1.4.5/lib/rack/utils.rb"
244
+ },
245
+ {
246
+ "method": "decode_www_form_component",
247
+ "lineno": 898,
248
+ "filename": "/home/travis/.rvm/rubies/rbx/gems/gems/rubysl-uri-2.0.0/lib/uri/common.rb"
249
+ }
250
+ ],
251
+ "exception": {
252
+ "message": "invalid %-encoding (8%B)",
253
+ "class": "ArgumentError"
254
+ }
255
+ }
256
+ },
257
+ "uuid": "d9a419d7-7b11-4435-bf5a-ffaa0fa9ff8c",
258
+ "language": "ruby",
259
+ "level": "error",
260
+ "timestamp": 1416877955,
261
+ "server": {
262
+ "pid": 3586,
263
+ "host": "testing-worker-linux-docker-eeafdf0f-2420-linux-9",
264
+ "root": "/home/travis/build/rollbar/rollbar-gem/spec/dummyapp"
265
+ },
266
+ "environment": "unspecified",
267
+ "framework": "Rails: 3.2.17",
268
+ "notifier": {
269
+ "version": "1.2.9",
270
+ "name": "rollbar-gem"
271
+ },
272
+ "metadata": {
273
+ "customer_timestamp": 1416877955
274
+ }
275
+ }