bugsnag 4.0.2 → 4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a229f778796995938a5bc4d2e1f6260e8b5ad975
4
- data.tar.gz: 2bf93ba3af00b2aa7e1038b2863c0dcab591dbc4
3
+ metadata.gz: 270f44756bef1cd0216474d1d63bed40fc4bfdb2
4
+ data.tar.gz: c9848a9c9ab917581749ad1c1e5eb98b97c3c950
5
5
  SHA512:
6
- metadata.gz: d84f962040e273a06bcc392df1b157445ef31db06772e998fb005f9477e64f5d7ebe89cd96184cc45315cb51bfb1183c84e41ca1104b39db8cc2207f1a9a3356
7
- data.tar.gz: 4ebd9be31fe102764c9b9eec6920e8d51685b02669be624470187ee4f3b42884cee2a188a05cfbbe4445c350969169fb52556f0580779093cf4c2a7942bf3748
6
+ metadata.gz: aa1811e86e5526cb984946fd2b8082bcdf5da3b48aaec1fc62e56f2396cd799b37a23fb35dad30baa771e4ae3824663b4a2551541e079e7ccb46aaa3f5812c1e
7
+ data.tar.gz: 5fc7427a1f8475b38d8f599d73b624d71d69002c79806be5c133adc146bba0001c00778c0e548896870729c2971299156b2aea27e6965eecef076038784b18c7
@@ -1,6 +1,20 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 4.1.0 (11 May 2016)
5
+
6
+ ### Enhancements
7
+
8
+ * Add support for 'block syntax' on Bugsnag.notify calls
9
+ | [James Smith](https://github.com/loopj)
10
+ | [#292](https://github.com/bugsnag/bugsnag-ruby/pull/292)
11
+
12
+ ### Fixes
13
+
14
+ * Trim stacktraces and metadata to ensure payload delivery
15
+ | [#294](https://github.com/bugsnag/bugsnag-ruby/issues/294)
16
+ | [#295](https://github.com/bugsnag/bugsnag-ruby/pull/295)
17
+
4
18
  ## 4.0.2 (13 Apr 2016)
5
19
 
6
20
  ### Fixes
@@ -41,3 +41,7 @@ If you're a member of the core team, follow these instructions for releasing bug
41
41
  ```
42
42
 
43
43
  * Update the version running in the bugsnag-website project
44
+
45
+ ### Update docs.bugsnag.com
46
+
47
+ Update the setup guides for Ruby (and its frameworks) with any new content.
data/README.md CHANGED
@@ -188,8 +188,17 @@ If you would like to send non-fatal exceptions to Bugsnag, you can call
188
188
  Bugsnag.notify(RuntimeError.new("Something broke"))
189
189
  ```
190
190
 
191
- Additional data can be sent with exceptions as an options hash as detailed in the [Notification Options](https://github.com/bugsnag/bugsnag-ruby/tree/master/docs/Notification Options.md) documentation, including some [options specific to non-fatal exceptions](https://github.com/bugsnag/bugsnag-ruby/tree/master/docs/Notification Options.md#handled-notification-options).
191
+ Additional information can be attached to a notification using a configuration
192
+ block:
192
193
 
194
+ ```ruby
195
+ Bugsnag.notify(RuntimeError.new("Something broke")) do |notif|
196
+ notif.severity = 'warning'
197
+ end
198
+ ```
199
+
200
+ The complete list of available properties is available in
201
+ [the documentation for the `Notification` object](https://github.com/bugsnag/bugsnag-ruby/blob/master/docs/Notification%20Options.md#notification-object)
193
202
 
194
203
  ### Callbacks
195
204
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.2
1
+ 4.1.0
@@ -53,16 +53,21 @@ module Bugsnag
53
53
  end
54
54
 
55
55
  # Explicitly notify of an exception
56
- def notify(exception, overrides=nil, request_data=nil)
56
+ def notify(exception, overrides=nil, request_data=nil, &block)
57
57
  notification = Notification.new(exception, configuration, overrides, request_data)
58
+
59
+ yield(notification) if block_given?
60
+
58
61
  notification.deliver
59
62
  notification
60
63
  end
61
64
 
62
65
  # Notify of an exception unless it should be ignored
63
- def notify_or_ignore(exception, overrides=nil, request_data=nil)
66
+ def notify_or_ignore(exception, overrides=nil, request_data=nil, &block)
64
67
  notification = Notification.new(exception, configuration, overrides, request_data)
65
68
 
69
+ yield(notification) if block_given?
70
+
66
71
  unless notification.ignore?
67
72
  notification.deliver
68
73
  notification
@@ -74,10 +79,10 @@ module Bugsnag
74
79
  # Auto notify of an exception, called from rails and rack exception
75
80
  # rescuers, unless auto notification is disabled, or we should ignore this
76
81
  # error class
77
- def auto_notify(exception, overrides=nil, request_data=nil)
82
+ def auto_notify(exception, overrides=nil, request_data=nil, &block)
78
83
  overrides ||= {}
79
84
  overrides.merge!({:severity => "error"})
80
- notify_or_ignore(exception, overrides, request_data) if configuration.auto_notify
85
+ notify_or_ignore(exception, overrides, request_data, &block) if configuration.auto_notify
81
86
  end
82
87
 
83
88
  # Log wrapper
@@ -5,9 +5,9 @@ require 'json' unless defined?(JSON)
5
5
 
6
6
  module Bugsnag
7
7
  module Helpers
8
- MAX_STRING_LENGTH = 4096
8
+ MAX_STRING_LENGTH = 3072
9
9
  MAX_PAYLOAD_LENGTH = 128000
10
- MAX_ARRAY_LENGTH = 400
10
+ MAX_ARRAY_LENGTH = 40
11
11
  RAW_DATA_TYPES = [Numeric, TrueClass, FalseClass]
12
12
 
13
13
  # Trim the size of value if the serialized JSON value is longer than is
@@ -17,7 +17,9 @@ module Bugsnag
17
17
  return sanitized_value unless payload_too_long?(sanitized_value)
18
18
  reduced_value = trim_strings_in_value(sanitized_value)
19
19
  return reduced_value unless payload_too_long?(reduced_value)
20
- truncate_arrays_in_value(reduced_value)
20
+ reduced_value = truncate_arrays_in_value(reduced_value)
21
+ return reduced_value unless payload_too_long?(reduced_value)
22
+ remove_metadata_from_events(reduced_value)
21
23
  end
22
24
 
23
25
  def self.flatten_meta_data(overrides)
@@ -42,13 +44,11 @@ module Bugsnag
42
44
  TRUNCATION_INFO = '[TRUNCATED]'
43
45
 
44
46
  # Shorten array until it fits within the payload size limit when serialized
45
- def self.truncate_arrays(array)
47
+ def self.truncate_array(array)
46
48
  return [] unless array.respond_to?(:slice)
47
- array = array.slice(0, MAX_ARRAY_LENGTH)
48
- while array.length > 0 and payload_too_long?(array)
49
- array = array.slice(0, array.length - 1)
49
+ array.slice(0, MAX_ARRAY_LENGTH).map do |item|
50
+ truncate_arrays_in_value(item)
50
51
  end
51
- array
52
52
  end
53
53
 
54
54
  # Trim all strings to be less than the maximum allowed string length
@@ -101,12 +101,21 @@ module Bugsnag
101
101
  when Hash
102
102
  truncate_arrays_in_hash(value)
103
103
  when Array, Set
104
- truncate_arrays(value)
104
+ truncate_array(value)
105
105
  else
106
106
  value
107
107
  end
108
108
  end
109
109
 
110
+ # Remove `metaData` from array of `events` within object
111
+ def self.remove_metadata_from_events(object)
112
+ return {} unless object.is_a?(Hash) and object[:events].respond_to?(:map)
113
+ object[:events].map do |event|
114
+ event.delete(:metaData) if object.is_a?(Hash)
115
+ end
116
+ object
117
+ end
118
+
110
119
  def self.truncate_arrays_in_hash(hash)
111
120
  return {} unless hash.is_a?(Hash)
112
121
  hash.each_with_object({}) do |(key, value), reduced_hash|
@@ -135,16 +135,28 @@ describe Bugsnag::Helpers do
135
135
 
136
136
  context "and trimmed strings are not enough" do
137
137
  it "truncates long arrays" do
138
- value = 100.times.map {|i| SecureRandom.hex(8192) }
138
+ value = [100.times.map {|i| SecureRandom.hex(8192) }, "a"]
139
139
  trimmed_value = Bugsnag::Helpers.trim_if_needed(value)
140
- expect(trimmed_value.length).to be > 0
141
- trimmed_value.each do |str|
140
+ expect(trimmed_value.length).to eq 2
141
+ expect(trimmed_value.first.length).to eq Bugsnag::Helpers::MAX_ARRAY_LENGTH
142
+ trimmed_value.first.each do |str|
142
143
  expect(str.match(/\[TRUNCATED\]$/)).to_not be_nil
143
144
  expect(str.length).to eq(Bugsnag::Helpers::MAX_STRING_LENGTH)
144
145
  end
145
146
 
146
147
  expect(::JSON.dump(trimmed_value).length).to be < Bugsnag::Helpers::MAX_PAYLOAD_LENGTH
147
148
  end
149
+
150
+ it "removes metadata from events" do
151
+ metadata = Hash[*20000.times.map {|i| [i,i+1]}.flatten]
152
+ frames = 100.times.map {|i| SecureRandom.hex(4096) }
153
+ value = {key:"abc", events:[{metaData: metadata, frames: frames, cake: "carrot"}]}
154
+ trimmed_value = Bugsnag::Helpers.trim_if_needed(value)
155
+ expect(::JSON.dump(trimmed_value).length).to be < Bugsnag::Helpers::MAX_PAYLOAD_LENGTH
156
+ expect(trimmed_value[:key]).to eq value[:key]
157
+ expect(trimmed_value[:events].first.keys.to_set).to eq [:frames, :cake].to_set
158
+ expect(trimmed_value[:events].first[:metaData]).to be_nil
159
+ end
148
160
  end
149
161
  end
150
162
  end
@@ -335,6 +335,17 @@ describe Bugsnag::Notification do
335
335
  }
336
336
  end
337
337
 
338
+ it "lets you override severity using block syntax" do
339
+ Bugsnag.notify(BugsnagTestException.new("It crashed")) do |notification|
340
+ notification.severity = "info"
341
+ end
342
+
343
+ expect(Bugsnag).to have_sent_notification{ |payload|
344
+ event = get_event_from_payload(payload)
345
+ expect(event["severity"]).to eq("info")
346
+ }
347
+ end
348
+
338
349
  it "autonotifies errors" do
339
350
  Bugsnag.auto_notify(BugsnagTestException.new("It crashed"))
340
351
 
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-13 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 10.1.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 10.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: addressable
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.3.8
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.3.8
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: Ruby notifier for bugsnag.com
@@ -103,10 +103,10 @@ extra_rdoc_files:
103
103
  - README.md
104
104
  - CHANGELOG.md
105
105
  files:
106
- - .document
107
- - .gitignore
108
- - .rspec
109
- - .travis.yml
106
+ - ".document"
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".travis.yml"
110
110
  - CHANGELOG.md
111
111
  - CONTRIBUTING.md
112
112
  - Gemfile
@@ -181,17 +181,17 @@ require_paths:
181
181
  - lib
182
182
  required_ruby_version: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - '>='
184
+ - - ">="
185
185
  - !ruby/object:Gem::Version
186
186
  version: 1.9.2
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  requirements:
189
- - - '>='
189
+ - - ">="
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.0.14.1
194
+ rubygems_version: 2.4.5
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Ruby notifier for bugsnag.com