bugsnag 1.8.8 → 2.0.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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +37 -9
- data/VERSION +1 -1
- data/bugsnag.gemspec +1 -0
- data/lib/bugsnag.rb +1 -0
- data/lib/bugsnag/capistrano2.rb +14 -26
- data/lib/bugsnag/delayed_job.rb +7 -0
- data/lib/bugsnag/deploy.rb +45 -0
- data/lib/bugsnag/helpers.rb +19 -4
- data/lib/bugsnag/notification.rb +18 -5
- data/lib/bugsnag/rake.rb +19 -10
- data/lib/bugsnag/sidekiq.rb +11 -3
- data/lib/bugsnag/tasks/bugsnag.cap +13 -27
- data/lib/bugsnag/tasks/bugsnag.rake +15 -63
- data/spec/notification_spec.rb +41 -2
- metadata +36 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8747ea8d79be63f2a884d5c595a4d0faf946e0bf
|
4
|
+
data.tar.gz: ddd5564d323f74a0d27d6adc89725ddab1d4dbdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e459123fbdc0e0fba0824e4f34bbf035144eda2e797ebf28652301af01f8f4274a42e287f3f666700b7c1e74a3acd284322a4358b489669f9a4a42e933ea9af5
|
7
|
+
data.tar.gz: 5ee52a9b0982be48dd089b2a2315c3fe8b79d7ca735e1968de0106ce79ee358600406cef1f60936ac3165f555ad3f3de57043dded54958a93a369612ecc5514f
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
2.0.0
|
5
|
+
-----
|
6
|
+
- BREAKING: capistrano integration requires explicit configuration to avoid loading rails env (15x faster to notify)
|
7
|
+
- Sidekiq 3 support
|
8
|
+
- java.lang.Throwable support for jruby
|
9
|
+
- Show non-serializable objects as '[Object]' instead of 'null'.
|
10
|
+
- Fix delayed job 2.x
|
11
|
+
- Fix rake support
|
12
|
+
- Fix missing notifications caused by invalid utf8
|
13
|
+
|
4
14
|
1.8.8
|
5
15
|
-----
|
6
16
|
- Prepare 'severity' feature for release
|
data/README.md
CHANGED
@@ -148,7 +148,7 @@ You can read more about how callbacks work in the
|
|
148
148
|
[Bugsnag Middleware](#bugsnag-middleware) documentation below.
|
149
149
|
|
150
150
|
|
151
|
-
Sending
|
151
|
+
Sending Handled Exceptions
|
152
152
|
----------------------------
|
153
153
|
|
154
154
|
If you would like to send non-fatal exceptions to Bugsnag, you can call
|
@@ -158,15 +158,36 @@ If you would like to send non-fatal exceptions to Bugsnag, you can call
|
|
158
158
|
Bugsnag.notify(RuntimeError.new("Something broke"))
|
159
159
|
```
|
160
160
|
|
161
|
+
### Custom Data
|
162
|
+
|
161
163
|
You can also send additional meta-data with your exception:
|
162
164
|
|
163
165
|
```ruby
|
164
166
|
Bugsnag.notify(RuntimeError.new("Something broke"), {
|
165
|
-
:
|
166
|
-
|
167
|
+
:user => {
|
168
|
+
:username => "bob-hoskins",
|
169
|
+
:registered_user => true
|
170
|
+
}
|
171
|
+
})
|
172
|
+
```
|
173
|
+
|
174
|
+
### Severity
|
175
|
+
|
176
|
+
You can set the severity of an error in Bugsnag by including the severity option when
|
177
|
+
notifying bugsnag of the error,
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
Bugsnag.notify(RuntimeError.new("Something broke"), {
|
181
|
+
:severity => "error",
|
167
182
|
})
|
168
183
|
```
|
169
184
|
|
185
|
+
Valid severities are `error`, `warning` and `info`.
|
186
|
+
|
187
|
+
Severity is displayed in the dashboard and can be used to filter the error list.
|
188
|
+
By default all crashes (or unhandled exceptions) are set to `error` and all
|
189
|
+
`Bugsnag.notify` calls default to `warning`.
|
190
|
+
|
170
191
|
Rake Integration
|
171
192
|
----------------
|
172
193
|
|
@@ -256,7 +277,7 @@ apps it is automatically set to `RACK_ENV`. Otherwise the default is
|
|
256
277
|
###notify_release_stages
|
257
278
|
|
258
279
|
By default, we will notify Bugsnag of exceptions that happen in any
|
259
|
-
`release_stage`. If you would like to change which release stages
|
280
|
+
`release_stage`. If you would like to change which release stages
|
260
281
|
notify Bugsnag of exceptions you can set `notify_release_stages`:
|
261
282
|
|
262
283
|
```ruby
|
@@ -493,11 +514,13 @@ introduced in.
|
|
493
514
|
### Using Capistrano
|
494
515
|
|
495
516
|
If you use [capistrano](https://github.com/capistrano/capistrano) to deploy
|
496
|
-
your apps, you can enable deploy tracking by adding the
|
517
|
+
your apps, you can enable deploy tracking by adding the integration to your
|
497
518
|
app's `deploy.rb`:
|
498
519
|
|
499
520
|
```ruby
|
500
521
|
require "bugsnag/capistrano"
|
522
|
+
|
523
|
+
set :bugsnag_api_key, "api_key_here"
|
501
524
|
```
|
502
525
|
|
503
526
|
### Using Rake
|
@@ -506,7 +529,7 @@ If you aren't using capistrano, you can run the following rake command from
|
|
506
529
|
your deploy scripts.
|
507
530
|
|
508
531
|
```shell
|
509
|
-
rake bugsnag:deploy BUGSNAG_REVISION=source-control-revision BUGSNAG_RELEASE_STAGE=production
|
532
|
+
rake bugsnag:deploy BUGSNAG_REVISION=source-control-revision BUGSNAG_RELEASE_STAGE=production BUGSNAG_API_KEY=api-key-here
|
510
533
|
```
|
511
534
|
|
512
535
|
The bugsnag rake tasks will be automatically available for Rails 3/4
|
@@ -522,13 +545,12 @@ require "bugsnag/tasks"
|
|
522
545
|
You can set the following environmental variables to override or specify
|
523
546
|
additional deploy information:
|
524
547
|
|
548
|
+
- **BUGSNAG_API_KEY** -
|
549
|
+
Your Bugsnag API key (required).
|
525
550
|
- **BUGSNAG_RELEASE_STAGE** -
|
526
551
|
The release stage (eg, production, staging) currently being deployed.
|
527
552
|
This is set automatically from your Bugsnag settings or rails/rack
|
528
553
|
environment.
|
529
|
-
- **BUGSNAG_API_KEY** -
|
530
|
-
Your Bugsnag API key. This is set automatically from your Bugsnag
|
531
|
-
settings in your app.
|
532
554
|
- **BUGSNAG_REPOSITORY** -
|
533
555
|
The repository from which you are deploying the code. This is set
|
534
556
|
automatically if you are using capistrano.
|
@@ -576,6 +598,12 @@ end
|
|
576
598
|
For this to work, include [Deferrable](http://eventmachine.rubyforge.org/EventMachine/Deferrable.html)
|
577
599
|
in your `MyServer`, then whenever you want to raise an error, call `fail`.
|
578
600
|
|
601
|
+
### Integrations
|
602
|
+
|
603
|
+
Bugsnag ruby works out of the box with Rails, Sidekiq, Resque, DelayedJob (3+), Mailman, Rake and Rack. It
|
604
|
+
should be easy to add support for other frameworks, either by sending a pull request here or adding a hook
|
605
|
+
to those projects.
|
606
|
+
|
579
607
|
Reporting Bugs or Feature Requests
|
580
608
|
----------------------------------
|
581
609
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/bugsnag.gemspec
CHANGED
data/lib/bugsnag.rb
CHANGED
data/lib/bugsnag/capistrano2.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
+
require "bugsnag/deploy"
|
2
|
+
|
1
3
|
module Bugsnag
|
2
4
|
module Capistrano
|
3
|
-
ALLOWED_ENV_SETTINGS = %w{BUGSNAG_RELEASE_STAGE BUGSNAG_REPOSITORY BUGSNAG_REVISION BUGSNAG_BRANCH BUGSNAG_API_KEY BUGSNAG_APP_VERSION}
|
4
|
-
|
5
5
|
def self.load_into(configuration)
|
6
6
|
configuration.load do
|
7
7
|
after "deploy", "bugsnag:deploy"
|
@@ -10,29 +10,18 @@ module Bugsnag
|
|
10
10
|
namespace :bugsnag do
|
11
11
|
desc "Notify Bugsnag that new production code has been deployed"
|
12
12
|
task :deploy, :except => { :no_release => true }, :on_error => :continue do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
"
|
24
|
-
|
25
|
-
"BUGSNAG_API_KEY" => fetch(:bugsnag_api_key, nil)
|
26
|
-
}.reject { |_, v| v.nil? }
|
27
|
-
|
28
|
-
# Pass through any existing env variables
|
29
|
-
ALLOWED_ENV_SETTINGS.each { |opt| new_env[opt] = ENV[opt] if ENV[opt] }
|
30
|
-
|
31
|
-
# Append the env to the rake command
|
32
|
-
rake_command << " #{new_env.map{|k,v| "#{k}=#{v}"}.join(" ")}"
|
33
|
-
|
34
|
-
# Run the rake command (only on one server)
|
35
|
-
run(rake_command, :once => true)
|
13
|
+
begin
|
14
|
+
Bugsnag::Deploy.notify({
|
15
|
+
:api_key => fetch(:bugsnag_api_key, ENV["BUGSNAG_API_KEY"]),
|
16
|
+
:release_stage => fetch(:rails_env, ENV["BUGSNAG_RELEASE_STAGE"] || "production"),
|
17
|
+
:revision => fetch(:current_revision, ENV["BUGSNAG_REPOSITORY"]),
|
18
|
+
:repository => fetch(:repository, ENV["BUGSNAG_REVISION"]),
|
19
|
+
:branch => fetch(:branch, ENV["BUGSNAG_BRANCH"],
|
20
|
+
:app_version => fetch(:app_version, ENV["BUGSNAG_APP_VERSION"]))
|
21
|
+
})
|
22
|
+
rescue
|
23
|
+
logger.important("Bugnsag deploy notification failed, #{$!.inspect}")
|
24
|
+
end
|
36
25
|
|
37
26
|
logger.info "Bugsnag deploy notification complete."
|
38
27
|
end
|
@@ -43,4 +32,3 @@ module Bugsnag
|
|
43
32
|
end
|
44
33
|
|
45
34
|
Bugsnag::Capistrano.load_into(Capistrano::Configuration.instance) if Capistrano::Configuration.instance
|
46
|
-
|
data/lib/bugsnag/delayed_job.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
require 'delayed_job'
|
2
2
|
|
3
|
+
# See Issue #99
|
4
|
+
unless defined?(Delayed::Plugins::Plugin)
|
5
|
+
raise LoadError, "bugsnag requires delayed_job > 3.x"
|
6
|
+
end
|
7
|
+
|
3
8
|
unless defined? Delayed::Plugins::Bugsnag
|
4
9
|
module Delayed
|
5
10
|
module Plugins
|
11
|
+
|
12
|
+
|
6
13
|
class Bugsnag < Plugin
|
7
14
|
module Notify
|
8
15
|
def error(job, error)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "uri"
|
3
|
+
require "bugsnag"
|
4
|
+
|
5
|
+
module Bugsnag
|
6
|
+
class Deploy
|
7
|
+
def self.notify(opts = {})
|
8
|
+
opts[:api_key] ||= Bugsnag.configuration.api_key
|
9
|
+
opts[:release_stage] ||= "production"
|
10
|
+
opts[:endpoint] ||= Bugsnag.configuration.endpoint
|
11
|
+
opts[:use_ssl] = Bugsnag.configuration.use_ssl if opts[:use_ssl] == nil
|
12
|
+
opts[:proxy_host] ||= Bugsnag.configuration.proxy_host
|
13
|
+
opts[:proxy_port] ||= Bugsnag.configuration.proxy_port
|
14
|
+
opts[:proxy_user] ||= Bugsnag.configuration.proxy_user
|
15
|
+
opts[:proxy_password] ||= Bugsnag.configuration.proxy_password
|
16
|
+
|
17
|
+
endpoint = (opts[:use_ssl] ? "https://" : "http://") + opts[:endpoint] + "/deploy"
|
18
|
+
|
19
|
+
parameters = {
|
20
|
+
"apiKey" => opts[:api_key],
|
21
|
+
"releaseStage" => opts[:release_stage],
|
22
|
+
"appVersion" => opts[:app_version],
|
23
|
+
"revision" => opts[:revision],
|
24
|
+
"repository" => opts[:repository],
|
25
|
+
"branch" => opts[:branch]
|
26
|
+
}.reject {|k,v| v == nil}
|
27
|
+
|
28
|
+
raise RuntimeError.new("No API key found when notifying of deploy") if !parameters["apiKey"] || parameters["apiKey"].empty?
|
29
|
+
|
30
|
+
uri = URI.parse(endpoint)
|
31
|
+
req = Net::HTTP::Post.new(uri.path)
|
32
|
+
req.set_form_data(parameters)
|
33
|
+
http = Net::HTTP.new(
|
34
|
+
uri.host,
|
35
|
+
uri.port,
|
36
|
+
opts[:proxy_host],
|
37
|
+
opts[:proxy_port],
|
38
|
+
opts[:proxy_user],
|
39
|
+
opts[:proxy_password]
|
40
|
+
)
|
41
|
+
http.use_ssl = true if opts[:use_ssl]
|
42
|
+
http.request(req)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/bugsnag/helpers.rb
CHANGED
@@ -23,7 +23,8 @@ module Bugsnag
|
|
23
23
|
seen << obj
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
case obj
|
27
|
+
when Hash
|
27
28
|
clean_hash = {}
|
28
29
|
obj.each do |k,v|
|
29
30
|
if filters && filters.any? {|f| k.to_s.include?(f.to_s)}
|
@@ -34,12 +35,26 @@ module Bugsnag
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
clean_hash
|
37
|
-
|
38
|
+
when Array, Set
|
38
39
|
obj.map { |el| cleanup_obj(el, filters, seen) }.compact
|
39
|
-
|
40
|
+
when Numeric
|
40
41
|
obj
|
42
|
+
when String
|
43
|
+
if defined?(obj.encoding) && defined?(Encoding::UTF_8)
|
44
|
+
obj.encode('utf-8', obj.encoding == Encoding::UTF_8 ? 'binary' : obj.encoding, :invalid => :replace, :undef => :replace)
|
45
|
+
elsif defined?(Iconv)
|
46
|
+
Iconv.conv('UTF-8//IGNORE', 'UTF-8', obj) || obj
|
47
|
+
else
|
48
|
+
obj
|
49
|
+
end
|
41
50
|
else
|
42
|
-
|
51
|
+
str = obj.to_s
|
52
|
+
# avoid leaking potentially sensitive data from objects' #inspect output
|
53
|
+
if str =~ /#<.*>/
|
54
|
+
'[OBJECT]'
|
55
|
+
else
|
56
|
+
str
|
57
|
+
end
|
43
58
|
end
|
44
59
|
end
|
45
60
|
|
data/lib/bugsnag/notification.rb
CHANGED
@@ -11,8 +11,13 @@ module Bugsnag
|
|
11
11
|
NOTIFIER_URL = "http://www.bugsnag.com"
|
12
12
|
|
13
13
|
API_KEY_REGEX = /[0-9a-f]{32}/i
|
14
|
+
|
15
|
+
# e.g. "org/jruby/RubyKernel.java:1264:in `catch'"
|
14
16
|
BACKTRACE_LINE_REGEX = /^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$/
|
15
17
|
|
18
|
+
# e.g. "org.jruby.Ruby.runScript(Ruby.java:807)"
|
19
|
+
JAVA_BACKTRACE_REGEX = /^(.*)\((.*)(?::([0-9]+))?\)$/
|
20
|
+
|
16
21
|
MAX_EXCEPTIONS_TO_UNWRAP = 5
|
17
22
|
|
18
23
|
SUPPORTED_SEVERITIES = ["error", "warning", "info"]
|
@@ -75,16 +80,18 @@ module Bugsnag
|
|
75
80
|
@exceptions = []
|
76
81
|
ex = exception
|
77
82
|
while ex != nil && !@exceptions.include?(ex) && @exceptions.length < MAX_EXCEPTIONS_TO_UNWRAP
|
83
|
+
|
78
84
|
unless ex.is_a? Exception
|
79
85
|
if ex.respond_to?(:to_exception)
|
80
86
|
ex = ex.to_exception
|
81
87
|
elsif ex.respond_to?(:exception)
|
82
88
|
ex = ex.exception
|
83
89
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
90
|
+
end
|
91
|
+
|
92
|
+
unless ex.is_a?(Exception) || (defined?(Java::JavaLang::Throwable) && ex.is_a?(Java::JavaLang::Throwable))
|
93
|
+
Bugsnag.warn("Converting non-Exception to RuntimeError: #{ex.inspect}")
|
94
|
+
ex = RuntimeError.new(ex.to_s)
|
88
95
|
end
|
89
96
|
|
90
97
|
@exceptions << ex
|
@@ -331,8 +338,14 @@ module Bugsnag
|
|
331
338
|
|
332
339
|
def stacktrace(exception)
|
333
340
|
(exception.backtrace || caller).map do |trace|
|
341
|
+
|
342
|
+
if trace.match(BACKTRACE_LINE_REGEX)
|
343
|
+
file, line_str, method = [$1, $2, $3]
|
344
|
+
elsif trace.match(JAVA_BACKTRACE_REGEX)
|
345
|
+
method, file, line_str = [$1, $2, $3]
|
346
|
+
end
|
347
|
+
|
334
348
|
# Parse the stacktrace line
|
335
|
-
_, file, line_str, method = trace.match(BACKTRACE_LINE_REGEX).to_a
|
336
349
|
|
337
350
|
# Skip stacktrace lines inside lib/bugsnag
|
338
351
|
next(nil) if file.nil? || file =~ %r{lib/bugsnag}
|
data/lib/bugsnag/rake.rb
CHANGED
@@ -9,29 +9,38 @@ module Bugsnag::Rake
|
|
9
9
|
alias_method :define_task, :bugsnag_define_task
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
Bugsnag.before_notify_callbacks << lambda {|notif|
|
14
|
+
task = Thread.current[:bugsnag_running_task]
|
15
|
+
next unless task
|
16
|
+
|
17
|
+
notif.add_tab(:rake_task, {
|
18
|
+
:name => task.name,
|
19
|
+
:description => task.full_comment,
|
20
|
+
:arguments => task.arg_description
|
21
|
+
})
|
22
|
+
|
23
|
+
notif.context ||= task.name
|
24
|
+
}
|
12
25
|
end
|
13
26
|
|
14
27
|
module ClassMethods
|
15
28
|
def bugsnag_define_task(*args, &block)
|
16
|
-
task = self.original_define_task
|
29
|
+
task = self.original_define_task(*args) do |*block_args|
|
17
30
|
begin
|
18
|
-
|
19
|
-
|
20
|
-
:name => task.name,
|
21
|
-
:description => task.full_comment,
|
22
|
-
:arguments => task.arg_description
|
23
|
-
})
|
24
|
-
notif.context ||= task.name
|
25
|
-
}
|
31
|
+
old_task = Thread.current[:bugsnag_running_task]
|
32
|
+
Thread.current[:bugsnag_running_task] = task
|
26
33
|
|
27
34
|
yield(*block_args) if block_given?
|
28
35
|
rescue Exception => e
|
29
36
|
Bugsnag.auto_notify(e)
|
30
37
|
raise
|
38
|
+
ensure
|
39
|
+
Thread.current[:bugsnag_running_task] = old_task
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
34
43
|
end
|
35
44
|
end
|
36
45
|
|
37
|
-
Rake::Task.send(:include, Bugsnag::Rake) if defined?(Rake::Task)
|
46
|
+
Rake::Task.send(:include, Bugsnag::Rake) if defined?(Rake::Task)
|
data/lib/bugsnag/sidekiq.rb
CHANGED
@@ -21,8 +21,16 @@ module Bugsnag
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
::Sidekiq
|
25
|
-
|
26
|
-
|
24
|
+
if ::Sidekiq::VERSION < '3'
|
25
|
+
::Sidekiq.configure_server do |config|
|
26
|
+
config.server_middleware do |chain|
|
27
|
+
chain.add ::Bugsnag::Sidekiq
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
::Sidekiq.configure_server do |config|
|
32
|
+
config.error_handlers << lambda do |ex, ctx|
|
33
|
+
Bugsnag.auto_notify(ex, :sidekiq => ctx, :context => "sidekiq##{ctx['queue']}")
|
34
|
+
end
|
27
35
|
end
|
28
36
|
end
|
@@ -24,34 +24,20 @@ namespace :bugsnag do
|
|
24
24
|
|
25
25
|
desc 'Notify Bugsnag that new production code has been deployed'
|
26
26
|
task :deploy do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
"BUGSNAG_BRANCH" => fetch(:branch, nil),
|
39
|
-
"BUGSNAG_API_KEY" => fetch(:bugsnag_api_key, nil)
|
40
|
-
}.reject { |_, v| v.nil? }
|
41
|
-
|
42
|
-
# Pass through any existing env variables
|
43
|
-
ALLOWED_ENV_SETTINGS.each { |opt| new_env[opt] = ENV[opt] if ENV[opt] }
|
44
|
-
|
45
|
-
within release_path do
|
46
|
-
with rails_env: rails_env do
|
47
|
-
params = "bugsnag:deploy #{new_env.map{|k,v| "#{k}=#{v}"}.join(" ")}"
|
48
|
-
rake = fetch(:rake, "rake")
|
49
|
-
execute rake, params
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
info 'Bugsnag deploy notification complete.'
|
27
|
+
begin
|
28
|
+
Bugsnag::Deploy.notify({
|
29
|
+
:api_key => fetch(:bugsnag_api_key, ENV["BUGSNAG_API_KEY"]),
|
30
|
+
:release_stage => fetch(:bugsnag_env) || fetch(:rails_env) || fetch(:stage) || ENV["BUGSNAG_RELEASE_STAGE"] || "production",
|
31
|
+
:revision => fetch(:current_revision, ENV["BUGSNAG_REVISION"]),
|
32
|
+
:repository => fetch(:repo_url, ENV["BUGSNAG_REPOSITORY"]),
|
33
|
+
:branch => fetch(:branch, ENV["BUGSNAG_BRANCH"]),
|
34
|
+
:app_version => fetch(:app_version, ENV["BUGSNAG_APP_VERSION"])
|
35
|
+
})
|
36
|
+
rescue
|
37
|
+
important("Bugnsag deploy notification failed, #{$!.inspect}")
|
54
38
|
end
|
39
|
+
|
40
|
+
info 'Bugsnag deploy notification complete.'
|
55
41
|
end
|
56
42
|
|
57
43
|
end
|
@@ -1,71 +1,23 @@
|
|
1
1
|
require "bugsnag"
|
2
|
-
require "pathname"
|
3
|
-
require "httparty"
|
4
|
-
require "multi_json"
|
5
|
-
require "net/http"
|
6
|
-
require "uri"
|
7
2
|
|
8
3
|
namespace :bugsnag do
|
9
4
|
desc "Notify Bugsnag of a new deploy."
|
10
5
|
task :deploy do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
require initializer
|
27
|
-
else
|
28
|
-
yml_filename = path + 'config/bugsnag.yml'
|
29
|
-
config = YAML.load_file(yml_filename) if File.exists?(yml_filename)
|
30
|
-
Bugsnag.configure(config[releaseStage] ? config[releaseStage] : config) if config
|
31
|
-
end
|
32
|
-
|
33
|
-
config = Bugsnag.configuration
|
34
|
-
|
35
|
-
# Fetch and check the api key
|
36
|
-
api_key ||= config.api_key
|
37
|
-
raise RuntimeError.new("No API key found when notifying deploy") if !api_key || api_key.empty?
|
38
|
-
|
39
|
-
endpoint = (config.use_ssl ? "https://" : "http://") \
|
40
|
-
+ (config.endpoint || Bugsnag::Configuration::DEFAULT_ENDPOINT) \
|
41
|
-
+ "/deploy"
|
42
|
-
|
43
|
-
parameters = {
|
44
|
-
"apiKey" => api_key,
|
45
|
-
"releaseStage" => releaseStage,
|
46
|
-
"appVersion" => appVersion,
|
47
|
-
"revision" => revision,
|
48
|
-
"repository" => repository,
|
49
|
-
"branch" => branch
|
50
|
-
}
|
51
|
-
|
52
|
-
uri = URI.parse(endpoint)
|
53
|
-
req = Net::HTTP::Post.new(uri.path)
|
54
|
-
req.set_form_data(parameters)
|
55
|
-
http = Net::HTTP.new(
|
56
|
-
uri.host,
|
57
|
-
uri.port,
|
58
|
-
config.proxy_host,
|
59
|
-
config.proxy_port,
|
60
|
-
config.proxy_user,
|
61
|
-
config.proxy_password
|
62
|
-
)
|
63
|
-
http.use_ssl = true if config.use_ssl
|
64
|
-
http.request(req)
|
65
|
-
|
66
|
-
rescue Exception => e
|
67
|
-
Bugsnag.warn("Deploy notification failed, #{e.inspect}")
|
68
|
-
end
|
6
|
+
api_key = ENV["BUGSNAG_API_KEY"]
|
7
|
+
release_stage = ENV["BUGSNAG_RELEASE_STAGE"]
|
8
|
+
app_version = ENV["BUGSNAG_APP_VERSION"]
|
9
|
+
revision = ENV["BUGSNAG_REVISION"]
|
10
|
+
repository = ENV["BUGSNAG_REPOSITORY"]
|
11
|
+
branch = ENV["BUGSNAG_BRANCH"]
|
12
|
+
|
13
|
+
Bugsnag::Deploy.notify({
|
14
|
+
:api_key => api_key,
|
15
|
+
:release_stage => release_stage,
|
16
|
+
:app_version => app_version,
|
17
|
+
:revision => revision,
|
18
|
+
:repository => repository,
|
19
|
+
:branch => branch
|
20
|
+
})
|
69
21
|
end
|
70
22
|
|
71
23
|
desc "Send a test exception to Bugsnag."
|
data/spec/notification_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'securerandom'
|
3
4
|
require 'ostruct'
|
@@ -15,9 +16,19 @@ class Ruby21Exception < RuntimeError
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
19
|
+
class JRubyException
|
20
|
+
def self.raise!
|
21
|
+
new.gloops
|
22
|
+
end
|
23
|
+
|
24
|
+
def gloops
|
25
|
+
java.lang.System.out.printf(nil)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
18
29
|
describe Bugsnag::Notification do
|
19
|
-
def notify_test_exception
|
20
|
-
Bugsnag.notify(RuntimeError.new("test message"))
|
30
|
+
def notify_test_exception(*args)
|
31
|
+
Bugsnag.notify(RuntimeError.new("test message"), *args)
|
21
32
|
end
|
22
33
|
|
23
34
|
it "should contain an api_key if one is set" do
|
@@ -677,4 +688,32 @@ describe Bugsnag::Notification do
|
|
677
688
|
|
678
689
|
notify_test_exception
|
679
690
|
end
|
691
|
+
|
692
|
+
it "should fix invalid utf8" do
|
693
|
+
invalid_data = "fl\xc3ff"
|
694
|
+
invalid_data.force_encoding('BINARY') if invalid_data.respond_to?(:force_encoding)
|
695
|
+
|
696
|
+
expect(Bugsnag::Notification).to receive(:post) do |endpoint, opts|
|
697
|
+
expect(opts[:body]).to match(/fl�ff/) if defined?(Encoding::UTF_8)
|
698
|
+
end
|
699
|
+
|
700
|
+
notify_test_exception(:fluff => {:fluff => invalid_data})
|
701
|
+
end
|
702
|
+
|
703
|
+
if defined?(JRUBY_VERSION)
|
704
|
+
|
705
|
+
it "should work with java.lang.Throwables" do
|
706
|
+
expect(Bugsnag::Notification).to receive(:deliver_exception_payload) do |endpoint, payload|
|
707
|
+
expect(payload[:events][0][:exceptions][0][:errorClass]).to eq('Java::JavaLang::ArrayIndexOutOfBoundsException')
|
708
|
+
expect(payload[:events][0][:exceptions][0][:message]).to eq("2")
|
709
|
+
expect(payload[:events][0][:exceptions][0][:stacktrace].size).to be_gt(0)
|
710
|
+
end
|
711
|
+
|
712
|
+
begin
|
713
|
+
JRubyException.raise!
|
714
|
+
rescue
|
715
|
+
Bugsnag.notify $!
|
716
|
+
end
|
717
|
+
end
|
718
|
+
end
|
680
719
|
end
|
metadata
CHANGED
@@ -1,89 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugsnag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.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: 2014-04-
|
11
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
20
|
type: :runtime
|
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: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: httparty
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - <
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.0'
|
34
|
-
- -
|
34
|
+
- - '>='
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '0.6'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - <
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '1.0'
|
44
|
-
- -
|
44
|
+
- - '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0.6'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - '>='
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rspec
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- -
|
65
|
+
- - '>='
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rdoc
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - '>='
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: pry
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
87
101
|
- !ruby/object:Gem::Version
|
88
102
|
version: '0'
|
89
103
|
description: Ruby notifier for bugsnag.com
|
@@ -94,10 +108,10 @@ extra_rdoc_files:
|
|
94
108
|
- LICENSE.txt
|
95
109
|
- README.md
|
96
110
|
files:
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
111
|
+
- .document
|
112
|
+
- .gitignore
|
113
|
+
- .rspec
|
114
|
+
- .travis.yml
|
101
115
|
- CHANGELOG.md
|
102
116
|
- Gemfile
|
103
117
|
- LICENSE.txt
|
@@ -111,6 +125,7 @@ files:
|
|
111
125
|
- lib/bugsnag/configuration.rb
|
112
126
|
- lib/bugsnag/delay/resque.rb
|
113
127
|
- lib/bugsnag/delayed_job.rb
|
128
|
+
- lib/bugsnag/deploy.rb
|
114
129
|
- lib/bugsnag/helpers.rb
|
115
130
|
- lib/bugsnag/mailman.rb
|
116
131
|
- lib/bugsnag/meta_data.rb
|
@@ -151,17 +166,17 @@ require_paths:
|
|
151
166
|
- lib
|
152
167
|
required_ruby_version: !ruby/object:Gem::Requirement
|
153
168
|
requirements:
|
154
|
-
- -
|
169
|
+
- - '>='
|
155
170
|
- !ruby/object:Gem::Version
|
156
171
|
version: '0'
|
157
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
173
|
requirements:
|
159
|
-
- -
|
174
|
+
- - '>='
|
160
175
|
- !ruby/object:Gem::Version
|
161
176
|
version: '0'
|
162
177
|
requirements: []
|
163
178
|
rubyforge_project:
|
164
|
-
rubygems_version: 2.
|
179
|
+
rubygems_version: 2.0.3
|
165
180
|
signing_key:
|
166
181
|
specification_version: 4
|
167
182
|
summary: Ruby notifier for bugsnag.com
|