bugsnag 6.3.0.beta.0 → 6.3.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: b0643f03a70da437fa3983ee21f1f9ec4466085e
4
- data.tar.gz: bdcdb50f10d93babed837ad0f6ec3ad174c765b6
3
+ metadata.gz: 0f150d665aa4bbd126a1fcee6415449c764bfd8b
4
+ data.tar.gz: bacabc7aa6fc31be54613737742251ef95dd3cd7
5
5
  SHA512:
6
- metadata.gz: 4d4341b5a7e9566d16c4f9fee869d570824ee89a8092260f54c19791984241f163237beb564622850cb163479f5dff81d34860917f91f16eb639461bcca755f7
7
- data.tar.gz: 541e02bf501da119d9ddb4acde6ca3df1c2805c4513c7ab201a837d5d18e54a9eefbf95205fa5dd433b0f811d56c801fec3b53d871a696e9c7b8738db1b12c35
6
+ metadata.gz: 657d6eddccb62f4bd6e6c02f4f7c7220bcb89db9cca562dab98ad859c51d743be1dde6186a258ccd6b7c2ce1337a15ff1e966a2c53bc6fd6624d8ce32f8580fe
7
+ data.tar.gz: c229917814c152d2556fc3e161ebd7992da7d03ec7de27f96120bc2ca22888f88ab22aea8c5b3bce81cf302c7c6bfeb860a4a8dcb5a9d5a43a61e145804bc2d9
@@ -1,6 +1,13 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 6.3.0 (14 Dec 2017)
5
+
6
+ ### Enhancements
7
+
8
+ * Allow skipping report generation using exception property
9
+ | [#402](https://github.com/bugsnag/bugsnag-ruby/pull/402)
10
+
4
11
  ## 6.2.0 (07 Dec 2017)
5
12
 
6
13
  ### Enhancements
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.3.0.beta.0
1
+ 6.3.0
@@ -7,7 +7,6 @@ require "bugsnag/meta_data"
7
7
  require "bugsnag/report"
8
8
  require "bugsnag/cleaner"
9
9
  require "bugsnag/helpers"
10
- require "bugsnag/session_tracker"
11
10
 
12
11
  require "bugsnag/delivery"
13
12
  require "bugsnag/delivery/synchronous"
@@ -39,8 +38,6 @@ module Bugsnag
39
38
  configuration.warn("No valid API key has been set, notifications will not be sent")
40
39
  @key_warning = true
41
40
  end
42
-
43
- session_tracker.config = configuration
44
41
  end
45
42
 
46
43
  # Explicitly notify of an exception
@@ -65,6 +62,11 @@ module Bugsnag
65
62
  return
66
63
  end
67
64
 
65
+ if exception.respond_to?(:skip_bugsnag) && exception.skip_bugsnag
66
+ configuration.debug("Not notifying due to skip_bugsnag flag")
67
+ return
68
+ end
69
+
68
70
  report = Report.new(exception, configuration, auto_notify)
69
71
 
70
72
  # If this is an auto_notify we yield the block before the any middleware is run
@@ -111,8 +113,8 @@ module Bugsnag
111
113
 
112
114
  # Deliver
113
115
  configuration.info("Notifying #{configuration.endpoint} of #{report.exceptions.last[:errorClass]}")
114
- options = {:headers => report.headers, :trim_payload => true}
115
- Bugsnag::Delivery[configuration.delivery_method].deliver(configuration.endpoint, report.as_json, configuration, options)
116
+ payload_string = ::JSON.dump(Bugsnag::Helpers.trim_if_needed(report.as_json))
117
+ Bugsnag::Delivery[configuration.delivery_method].deliver(configuration.endpoint, payload_string, configuration)
116
118
  end
117
119
  end
118
120
 
@@ -122,11 +124,6 @@ module Bugsnag
122
124
  @configuration || LOCK.synchronize { @configuration ||= Bugsnag::Configuration.new }
123
125
  end
124
126
 
125
- def session_tracker
126
- @session_tracker = nil unless defined?(@session_tracker)
127
- @session_tracker || LOCK.synchronize { @session_tracker ||= Bugsnag::SessionTracker.new(configuration)}
128
- end
129
-
130
127
  # Allow access to "before notify" callbacks
131
128
  def before_notify_callbacks
132
129
  Bugsnag.configuration.request_data[:before_callbacks] ||= []
@@ -7,7 +7,6 @@ require "bugsnag/middleware/exception_meta_data"
7
7
  require "bugsnag/middleware/ignore_error_class"
8
8
  require "bugsnag/middleware/suggestion_data"
9
9
  require "bugsnag/middleware/classify_error"
10
- require "bugsnag/middleware/session_data"
11
10
 
12
11
  module Bugsnag
13
12
  class Configuration
@@ -23,7 +22,7 @@ module Bugsnag
23
22
  attr_accessor :app_type
24
23
  attr_accessor :meta_data_filters
25
24
  attr_accessor :endpoint
26
- attr_accessor :logger
25
+ attr_accessor :logger
27
26
  attr_accessor :middleware
28
27
  attr_accessor :internal_middleware
29
28
  attr_accessor :proxy_host
@@ -33,13 +32,10 @@ module Bugsnag
33
32
  attr_accessor :timeout
34
33
  attr_accessor :hostname
35
34
  attr_accessor :ignore_classes
36
- attr_accessor :track_sessions
37
- attr_accessor :session_endpoint
38
35
 
39
36
  API_KEY_REGEX = /[0-9a-f]{32}/i
40
37
  THREAD_LOCAL_NAME = "bugsnag_req_data"
41
38
  DEFAULT_ENDPOINT = "https://notify.bugsnag.com"
42
- DEFAULT_SESSION_ENDPOINT = "https://sessions.bugsnag.com"
43
39
 
44
40
  DEFAULT_META_DATA_FILTERS = [
45
41
  /authorization/i,
@@ -61,8 +57,6 @@ module Bugsnag
61
57
  self.hostname = default_hostname
62
58
  self.timeout = 15
63
59
  self.notify_release_stages = nil
64
- self.track_sessions = false
65
- self.session_endpoint = DEFAULT_SESSION_ENDPOINT
66
60
 
67
61
  # SystemExit and Interrupt are common Exception types seen with successful
68
62
  # exits and are not automatically reported to Bugsnag
@@ -87,7 +81,6 @@ module Bugsnag
87
81
  self.internal_middleware.use Bugsnag::Middleware::IgnoreErrorClass
88
82
  self.internal_middleware.use Bugsnag::Middleware::SuggestionData
89
83
  self.internal_middleware.use Bugsnag::Middleware::ClassifyError
90
- self.internal_middleware.use Bugsnag::Middleware::SessionData
91
84
 
92
85
  self.middleware = Bugsnag::MiddlewareStack.new
93
86
  self.middleware.use Bugsnag::Middleware::Callbacks
@@ -4,19 +4,13 @@ require "uri"
4
4
  module Bugsnag
5
5
  module Delivery
6
6
  class Synchronous
7
- BACKOFF_THREADS = {}
8
- BACKOFF_REQUESTS = {}
9
- BACKOFF_LOCK = Mutex.new
7
+ HEADERS = {"Content-Type" => "application/json"}
10
8
 
11
9
  class << self
12
- def deliver(url, body, configuration, options={})
10
+ def deliver(url, body, configuration)
13
11
  begin
14
- response = request(url, body, configuration, options)
12
+ response = request(url, body, configuration)
15
13
  configuration.debug("Request to #{url} completed, status: #{response.code}")
16
- success = options[:success] || '200'
17
- if options[:backoff] && !(response.code == success)
18
- backoff(url, body, configuration, options)
19
- end
20
14
  rescue StandardError => e
21
15
  # KLUDGE: Since we don't re-raise http exceptions, this breaks rspec
22
16
  raise if e.class.to_s == "RSpec::Expectations::ExpectationNotMetError"
@@ -28,14 +22,9 @@ module Bugsnag
28
22
 
29
23
  private
30
24
 
31
- def request(url, body, configuration, options)
25
+ def request(url, body, configuration)
32
26
  uri = URI.parse(url)
33
27
 
34
- if options[:trim_payload]
35
- body = Bugsnag::Helpers.trim_if_needed(body)
36
- end
37
- payload = ::JSON.dump(body)
38
-
39
28
  if configuration.proxy_host
40
29
  http = Net::HTTP.new(uri.host, uri.port, configuration.proxy_host, configuration.proxy_port, configuration.proxy_user, configuration.proxy_password)
41
30
  else
@@ -50,104 +39,14 @@ module Bugsnag
50
39
  http.ca_file = configuration.ca_file if configuration.ca_file
51
40
  end
52
41
 
53
- headers = options.key?(:headers) ? options[:headers] : {}
54
- headers.merge!(default_headers)
55
-
56
- request = Net::HTTP::Post.new(path(uri), headers)
57
- request.body = payload
58
-
42
+ request = Net::HTTP::Post.new(path(uri), HEADERS)
43
+ request.body = body
59
44
  http.request(request)
60
45
  end
61
46
 
62
- def backoff(url, body, configuration, options)
63
- # Ensure we have the latest configuration for making these requests
64
- @latest_configuration = configuration
65
-
66
- BACKOFF_LOCK.lock
67
- begin
68
- # Define an exit function once to handle outstanding requests
69
- @registered_at_exit = false unless defined?(@registered_at_exit)
70
- if !@registered_at_exit
71
- @registered_at_exit = true
72
- at_exit do
73
- backoff_exit
74
- end
75
- end
76
- if BACKOFF_REQUESTS[url] && !BACKOFF_REQUESTS[url].empty?
77
- last_request = BACKOFF_REQUESTS[url].last
78
- new_body_length = ::JSON.dump(body).length
79
- old_body_length = ::JSON.dump(last_request[:body]).length
80
- if new_body_length + old_body_length >= Bugsnag::Helpers::MAX_PAYLOAD_LENGTH
81
- BACKOFF_REQUESTS[url].push({:body => body, :options => options})
82
- else
83
- Bugsnag::Helpers::deep_merge!(last_request, {:body => body, :options => options})
84
- end
85
- else
86
- BACKOFF_REQUESTS[url] = [{:body => body, :options => options}]
87
- end
88
- if !(BACKOFF_THREADS[url] && BACKOFF_THREADS[url].status)
89
- spawn_backoff_thread(url)
90
- end
91
- ensure
92
- BACKOFF_LOCK.unlock
93
- end
94
- end
95
-
96
- def backoff_exit
97
- # Kill existing threads
98
- BACKOFF_THREADS.each do |url, thread|
99
- thread.exit
100
- end
101
- # Retry outstanding requests once, then exit
102
- BACKOFF_REQUESTS.each do |url, requests|
103
- requests.map! do |req|
104
- response = request(url, req[:body], @latest_configuration, req[:options])
105
- success = req[:options][:success] || '200'
106
- response.code == success
107
- end
108
- requests.reject! { |i| i }
109
- @latest_configuration.warn("Requests to #{url} finished, #{requests.size} failed")
110
- end
111
- end
112
-
113
- def spawn_backoff_thread(url)
114
- new_thread = Thread.new(url) do |url|
115
- interval = 2
116
- while BACKOFF_REQUESTS[url].size > 0
117
- sleep(interval)
118
- interval = interval * 2
119
- interval = 600 if interval > 600
120
- BACKOFF_LOCK.lock
121
- begin
122
- BACKOFF_REQUESTS[url].map! do |req|
123
- response = request(url, req[:body], @latest_configuration, req[:options])
124
- success = req[:options][:success] || '200'
125
- if response.code == success
126
- @latest_configuration.debug("Request to #{url} completed, status: #{response.code}")
127
- false
128
- else
129
- req
130
- end
131
- end
132
- BACKOFF_REQUESTS[url].reject! { |i| !i }
133
- ensure
134
- BACKOFF_LOCK.unlock
135
- end
136
- end
137
- end
138
- BACKOFF_THREADS[url] = new_thread
139
- end
140
-
141
47
  def path(uri)
142
48
  uri.path == "" ? "/" : uri.path
143
49
  end
144
-
145
- def default_headers
146
- {
147
- "Content-Type" => "application/json",
148
- "Bugsnag-Sent-At" => Time.now().utc().strftime('%Y-%m-%dT%H:%M:%S')
149
- }
150
- end
151
50
  end
152
51
  end
153
52
  end
@@ -8,7 +8,7 @@ module Bugsnag
8
8
  MUTEX = Mutex.new
9
9
 
10
10
  class << self
11
- def deliver(url, body, configuration, options={})
11
+ def deliver(url, body, configuration)
12
12
  @configuration = configuration
13
13
 
14
14
  start_once!
@@ -19,7 +19,7 @@ module Bugsnag
19
19
  end
20
20
 
21
21
  # Add delivery to the worker thread
22
- @queue.push proc { super(url, body, configuration, options) }
22
+ @queue.push proc { super(url, body, configuration) }
23
23
  end
24
24
 
25
25
  private
@@ -23,30 +23,6 @@ module Bugsnag
23
23
  remove_metadata_from_events(reduced_value)
24
24
  end
25
25
 
26
- def self.deep_merge(l_hash, r_hash)
27
- l_hash.merge(r_hash) do |key, l_val, r_val|
28
- if l_val.is_a?(Hash) && r_val.is_a?(Hash)
29
- deep_merge(l_val, r_val)
30
- elsif l_val.is_a?(Array) && r_val.is_a?(Array)
31
- l_val.concat(r_val)
32
- else
33
- r_val
34
- end
35
- end
36
- end
37
-
38
- def self.deep_merge!(l_hash, r_hash)
39
- l_hash.merge!(r_hash) do |key, l_val, r_val|
40
- if l_val.is_a?(Hash) && r_val.is_a?(Hash)
41
- deep_merge(l_val, r_val)
42
- elsif l_val.is_a?(Array) && r_val.is_a?(Array)
43
- l_val.concat(r_val)
44
- else
45
- r_val
46
- end
47
- end
48
- end
49
-
50
26
  private
51
27
 
52
28
  TRUNCATION_INFO = '[TRUNCATED]'
@@ -34,7 +34,6 @@ module Bugsnag
34
34
  def call(env)
35
35
  # Set the request data for bugsnag middleware to use
36
36
  Bugsnag.configuration.set_request_data(:rack_env, env)
37
- Bugsnag.session_tracker.create_session
38
37
 
39
38
  begin
40
39
  response = @app.call(env)
@@ -5,7 +5,6 @@ module Bugsnag::Rails
5
5
  end
6
6
 
7
7
  module ClassMethods
8
-
9
8
  private
10
9
  def before_bugsnag_notify(*methods, &block)
11
10
  _add_bugsnag_notify_callback(:before_callbacks, *methods, &block)
@@ -17,9 +17,8 @@ module Bugsnag
17
17
 
18
18
  MAX_EXCEPTIONS_TO_UNWRAP = 5
19
19
 
20
- CURRENT_PAYLOAD_VERSION = "4.0"
20
+ CURRENT_PAYLOAD_VERSION = "2"
21
21
 
22
- attr_reader :unhandled
23
22
  attr_accessor :api_key
24
23
  attr_accessor :app_type
25
24
  attr_accessor :app_version
@@ -32,7 +31,6 @@ module Bugsnag
32
31
  attr_accessor :meta_data
33
32
  attr_accessor :raw_exceptions
34
33
  attr_accessor :release_stage
35
- attr_accessor :session
36
34
  attr_accessor :severity
37
35
  attr_accessor :severity_reason
38
36
  attr_accessor :user
@@ -94,7 +92,7 @@ module Bugsnag
94
92
  },
95
93
  exceptions: exceptions,
96
94
  groupingHash: grouping_hash,
97
- session: session,
95
+ payloadVersion: CURRENT_PAYLOAD_VERSION,
98
96
  severity: severity,
99
97
  severityReason: severity_reason,
100
98
  unhandled: @unhandled,
@@ -110,6 +108,7 @@ module Bugsnag
110
108
 
111
109
  # return the payload hash
112
110
  {
111
+ :apiKey => api_key,
113
112
  :notifier => {
114
113
  :name => NOTIFIER_NAME,
115
114
  :version => NOTIFIER_VERSION,
@@ -119,14 +118,6 @@ module Bugsnag
119
118
  }
120
119
  end
121
120
 
122
- def headers
123
- {
124
- "Bugsnag-Api-Key" => api_key,
125
- "Bugsnag-Payload-Version" => CURRENT_PAYLOAD_VERSION,
126
- "Bugsnag-Sent-At" => Time.now().utc().strftime('%Y-%m-%dT%H:%M:%S')
127
- }
128
- end
129
-
130
121
  def ignore?
131
122
  @should_ignore
132
123
  end
@@ -22,11 +22,6 @@ describe Bugsnag::Configuration do
22
22
  subject.delivery_method = :wow
23
23
  expect(subject.delivery_method).to eq(:wow)
24
24
  end
25
-
26
- it "should have sensible defaults for session tracking" do
27
- expect(subject.session_endpoint).to eq("https://sessions.bugsnag.com")
28
- expect(subject.track_sessions).to be false
29
- end
30
25
  end
31
26
 
32
27
  it "should have exit exception classes ignored by default" do
@@ -23,7 +23,7 @@ describe Bugsnag::Sidekiq do
23
23
  rescue
24
24
  end
25
25
 
26
- expect(Bugsnag).to have_sent_notification {|payload, headers|
26
+ expect(Bugsnag).to have_sent_notification {|payload|
27
27
  event = get_event_from_payload(payload)
28
28
  expect(event["metaData"]["sidekiq"]["msg"]["class"]).to eq("FailingWorker")
29
29
  expect(event["metaData"]["sidekiq"]["msg"]["args"]).to eq([-0])
@@ -16,7 +16,7 @@ describe Bugsnag::MiddlewareStack do
16
16
  Bugsnag.notify(BugsnagTestException.new("It crashed"))
17
17
  expect(callback_run_count).to eq(1)
18
18
 
19
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
19
+ expect(Bugsnag).to have_sent_notification{ |payload|
20
20
  event = get_event_from_payload(payload)
21
21
  expect(event["metaData"]["some_tab"]).not_to be_nil
22
22
  expect(event["metaData"]["some_tab"]["info"]).to eq("here")
@@ -37,7 +37,7 @@ describe Bugsnag::MiddlewareStack do
37
37
  Bugsnag.notify(BugsnagTestException.new("It crashed"))
38
38
  expect(callback_run_count).to eq(1)
39
39
 
40
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
40
+ expect(Bugsnag).to have_sent_notification{ |payload|
41
41
  event = get_event_from_payload(payload)
42
42
  expect(event["metaData"]["custom"]).not_to be_nil
43
43
  expect(event["metaData"]["custom"]["info"]).to eq("here")
@@ -56,7 +56,7 @@ describe Bugsnag::MiddlewareStack do
56
56
  Bugsnag.notify(BugsnagTestException.new("It crashed"))
57
57
  expect(callback_run_count).to eq(1)
58
58
 
59
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
59
+ expect(Bugsnag).to have_sent_notification{ |payload|
60
60
  event = get_event_from_payload(payload)
61
61
  expect(event["user"]).not_to be_nil
62
62
  expect(event["user"]["id"]).to eq("here")
@@ -73,7 +73,7 @@ describe Bugsnag::MiddlewareStack do
73
73
  report.meta_data.merge!({custom: {info: 'overridden'}})
74
74
  end
75
75
 
76
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
76
+ expect(Bugsnag).to have_sent_notification{ |payload|
77
77
  event = get_event_from_payload(payload)
78
78
  expect(event["metaData"]["custom"]).not_to be_nil
79
79
  expect(event["metaData"]["custom"]["info"]).to eq("overridden")
@@ -87,7 +87,7 @@ describe Bugsnag::MiddlewareStack do
87
87
  report.meta_data.merge!({custom: {info: 'overridden'}})
88
88
  end
89
89
 
90
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
90
+ expect(Bugsnag).to have_sent_notification{ |payload|
91
91
  event = get_event_from_payload(payload)
92
92
  expect(event["metaData"]["custom"]).not_to be_nil
93
93
  expect(event["metaData"]["custom"]["info"]).to eq("overridden")
@@ -97,7 +97,7 @@ describe Bugsnag::MiddlewareStack do
97
97
  it "does not have have before callbacks by default" do
98
98
  expect(Bugsnag.before_notify_callbacks.size).to eq(0)
99
99
  Bugsnag.notify(BugsnagTestException.new("It crashed"))
100
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
100
+ expect(Bugsnag).to have_sent_notification{ |payload|
101
101
  event = get_event_from_payload(payload)
102
102
  expect(event["metaData"].size).to eq(0)
103
103
  }
@@ -172,7 +172,7 @@ describe Bugsnag::MiddlewareStack do
172
172
 
173
173
  Bugsnag.notify(BugsnagTestException.new("It crashed"))
174
174
 
175
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
175
+ expect(Bugsnag).to have_sent_notification{ |payload|
176
176
  event = get_event_from_payload(payload)
177
177
  expect(event["metaData"]['test']['value']).to eq("abcdef*****3456")
178
178
  }
@@ -187,7 +187,7 @@ describe Bugsnag::MiddlewareStack do
187
187
  Bugsnag.notify(e)
188
188
  end
189
189
 
190
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
190
+ expect(Bugsnag).to have_sent_notification{ |payload|
191
191
  event = get_event_from_payload(payload)
192
192
  expect(event["metaData"]["error"]).to_not be_nil
193
193
  expect(event["metaData"]["error"]).to eq({"suggestion" => "prepend"})
@@ -205,7 +205,7 @@ describe Bugsnag::MiddlewareStack do
205
205
  Bugsnag.notify(e)
206
206
  end
207
207
 
208
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
208
+ expect(Bugsnag).to have_sent_notification{ |payload|
209
209
  event = get_event_from_payload(payload)
210
210
  expect(event["metaData"]["error"]).to be_nil
211
211
  }
@@ -240,7 +240,7 @@ describe Bugsnag::MiddlewareStack do
240
240
  }
241
241
  end
242
242
 
243
- expect(Bugsnag).to have_sent_notification{ |payload, headers|
243
+ expect(Bugsnag).to have_sent_notification{ |payload|
244
244
  event = get_event_from_payload(payload)
245
245
  expect(event["unhandled"]).to be true
246
246
  expect(event["severityReason"]).to eq({