airbrake 5.2.3 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake/rack/middleware.rb +2 -0
- data/lib/airbrake/rack/notice_builder.rb +2 -1
- data/lib/airbrake/rails/action_controller.rb +4 -2
- data/lib/airbrake/rails/active_job.rb +14 -2
- data/lib/airbrake/rake/task_ext.rb +10 -5
- data/lib/airbrake/version.rb +1 -1
- data/lib/generators/airbrake_initializer.rb.erb +0 -1
- data/spec/apps/rails/logs/50.log +19 -0
- data/spec/integration/rails/rails_spec.rb +18 -0
- data/spec/unit/rack/middleware_spec.rb +13 -0
- data/spec/unit/rack/notice_builder_spec.rb +10 -0
- data/spec/unit/rake/tasks_spec.rb +1 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a96428e2bedf218d51dbfa97b0a45dc64dd80346
|
4
|
+
data.tar.gz: 08300938d9bb375d0a7422e45bb540d8d67fe2ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a390a0c5451cbf3cd25a8f381780c20693359837b8c8fafe39e47c42d320d64ad00e8f0d46e4294515698fd81c6973551d18b57605ebbc8c61d9452679c80471
|
7
|
+
data.tar.gz: 361d10bbe6a3592ea1dd0eaedeb6f8551600026ebbc8586f06f359c14e0024d0d2e091027a0be9250201992878f5cba32673ce563498610c07acae4ce6e27a4b
|
@@ -39,7 +39,8 @@ module Airbrake
|
|
39
39
|
# @param [Exception] exception
|
40
40
|
# @return [Airbrake::Notice] the notice with extra information
|
41
41
|
def build_notice(exception)
|
42
|
-
notice = Airbrake.build_notice(exception)
|
42
|
+
return unless (notice = Airbrake.build_notice(exception))
|
43
|
+
|
43
44
|
NoticeBuilder.builders.each { |builder| builder.call(notice, @request) }
|
44
45
|
notice
|
45
46
|
end
|
@@ -13,7 +13,8 @@ module Airbrake
|
|
13
13
|
# Attaches information from the Rack env.
|
14
14
|
# @see Airbrake#notify, #notify_airbrake_sync
|
15
15
|
def notify_airbrake(exception, parameters = {}, notifier = :default)
|
16
|
-
|
16
|
+
return unless (notice = build_notice(exception))
|
17
|
+
Airbrake.notify(notice, parameters, notifier)
|
17
18
|
end
|
18
19
|
|
19
20
|
##
|
@@ -21,7 +22,8 @@ module Airbrake
|
|
21
22
|
# Attaches information from the Rack env.
|
22
23
|
# @see Airbrake#notify_sync, #notify_airbrake
|
23
24
|
def notify_airbrake_sync(exception, parameters = {}, notifier = :default)
|
24
|
-
|
25
|
+
return unless (notice = build_notice(exception))
|
26
|
+
Airbrake.notify_sync(notice, parameters, notifier)
|
25
27
|
end
|
26
28
|
|
27
29
|
##
|
@@ -6,15 +6,27 @@ module Airbrake
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
|
+
if ::Rails.application.config.respond_to?(:active_job)
|
10
|
+
active_job_cfg = ::Rails.application.config.active_job
|
11
|
+
is_resque_adapter = (active_job_cfg.queue_adapter == :resque)
|
12
|
+
end
|
13
|
+
|
9
14
|
rescue_from(Exception) do |exception|
|
10
|
-
notice = Airbrake.build_notice(exception)
|
15
|
+
next unless (notice = Airbrake.build_notice(exception))
|
11
16
|
|
12
17
|
notice[:context][:component] = 'active_job'
|
13
18
|
notice[:context][:action] = self.class.name
|
14
19
|
|
15
20
|
notice[:params] = as_json
|
16
21
|
|
17
|
-
|
22
|
+
# We special case Resque because it kills our workers by forking, so
|
23
|
+
# we use synchronous delivery instead.
|
24
|
+
if is_resque_adapter
|
25
|
+
Airbrake.notify_sync(notice)
|
26
|
+
else
|
27
|
+
Airbrake.notify(notice)
|
28
|
+
end
|
29
|
+
|
18
30
|
raise exception
|
19
31
|
end
|
20
32
|
end
|
@@ -18,7 +18,16 @@ module Rake
|
|
18
18
|
def execute(args = nil)
|
19
19
|
execute_without_airbrake(args)
|
20
20
|
rescue Exception => ex
|
21
|
-
|
21
|
+
notify_airbrake(ex, args)
|
22
|
+
raise ex
|
23
|
+
end
|
24
|
+
# rubocop:enable Lint/RescueException
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def notify_airbrake(exception, args)
|
29
|
+
return unless (notice = Airbrake.build_notice(exception))
|
30
|
+
|
22
31
|
notice[:context][:component] = 'rake'
|
23
32
|
notice[:context][:action] = name
|
24
33
|
notice[:params] = {
|
@@ -28,11 +37,7 @@ module Rake
|
|
28
37
|
}
|
29
38
|
|
30
39
|
Airbrake.notify_sync(notice)
|
31
|
-
raise ex
|
32
40
|
end
|
33
|
-
# rubocop:enable Lint/RescueException
|
34
|
-
|
35
|
-
private
|
36
41
|
|
37
42
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
|
38
43
|
def task_info
|
data/lib/airbrake/version.rb
CHANGED
@@ -51,7 +51,6 @@ Airbrake.configure do |c|
|
|
51
51
|
# https://github.com/airbrake/airbrake-ruby#ignore_environments
|
52
52
|
c.ignore_environments = %w(test)
|
53
53
|
|
54
|
-
|
55
54
|
# A list of parameters that should be filtered out of what is sent to
|
56
55
|
# Airbrake. By default, all "password" attributes will have their contents
|
57
56
|
# replaced.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Logfile created on 2016-05-10 16:31:24 +0300 by logger.rb/53141
|
2
|
+
D, [2016-05-10T16:31:25.086078 #98450] DEBUG -- : [1m[35m (0.3ms)[0m [1m[35mCREATE TABLE "books" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar) [0m
|
3
|
+
D, [2016-05-10T16:31:25.090933 #98450] DEBUG -- : [1m[35m (0.1ms)[0m [1m[35mCREATE TABLE "delayed_jobs" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "priority" integer DEFAULT 0 NOT NULL, "attempts" integer DEFAULT 0 NOT NULL, "handler" text NOT NULL, "last_error" text, "run_at" datetime, "locked_at" datetime, "failed_at" datetime, "locked_by" varchar, "queue" varchar, "created_at" datetime, "updated_at" datetime) [0m
|
4
|
+
D, [2016-05-10T16:31:25.091415 #98450] DEBUG -- : [1m[35m (0.3ms)[0m [1m[34mselect sqlite_version(*)[0m
|
5
|
+
D, [2016-05-10T16:31:25.091748 #98450] DEBUG -- : [1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "delayed_jobs_priority" ON "delayed_jobs" ("priority", "run_at")[0m
|
6
|
+
D, [2016-05-10T16:31:25.093052 #98450] DEBUG -- : [1m[35m (0.1ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
7
|
+
D, [2016-05-10T16:31:25.100105 #98450] DEBUG -- : [1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" ORDER BY "ar_internal_metadata"."key" ASC LIMIT ?[0m [["LIMIT", 1]]
|
8
|
+
D, [2016-05-10T16:31:25.104885 #98450] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
9
|
+
D, [2016-05-10T16:31:25.105700 #98450] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "test"], ["created_at", 2016-05-10 13:31:25 UTC], ["updated_at", 2016-05-10 13:31:25 UTC]]
|
10
|
+
D, [2016-05-10T16:31:25.105852 #98450] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m
|
11
|
+
D, [2016-05-10T16:31:45.880344 #98591] DEBUG -- : [1m[35m (0.3ms)[0m [1m[35mCREATE TABLE "books" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar) [0m
|
12
|
+
D, [2016-05-10T16:31:45.884666 #98591] DEBUG -- : [1m[35m (0.1ms)[0m [1m[35mCREATE TABLE "delayed_jobs" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "priority" integer DEFAULT 0 NOT NULL, "attempts" integer DEFAULT 0 NOT NULL, "handler" text NOT NULL, "last_error" text, "run_at" datetime, "locked_at" datetime, "failed_at" datetime, "locked_by" varchar, "queue" varchar, "created_at" datetime, "updated_at" datetime) [0m
|
13
|
+
D, [2016-05-10T16:31:45.884858 #98591] DEBUG -- : [1m[35m (0.0ms)[0m [1m[34mselect sqlite_version(*)[0m
|
14
|
+
D, [2016-05-10T16:31:45.885162 #98591] DEBUG -- : [1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "delayed_jobs_priority" ON "delayed_jobs" ("priority", "run_at")[0m
|
15
|
+
D, [2016-05-10T16:31:45.886357 #98591] DEBUG -- : [1m[35m (0.1ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
16
|
+
D, [2016-05-10T16:31:45.893923 #98591] DEBUG -- : [1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" ORDER BY "ar_internal_metadata"."key" ASC LIMIT ?[0m [["LIMIT", 1]]
|
17
|
+
D, [2016-05-10T16:31:45.900088 #98591] DEBUG -- : [1m[35m (0.1ms)[0m [1m[36mbegin transaction[0m
|
18
|
+
D, [2016-05-10T16:31:45.901437 #98591] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "test"], ["created_at", 2016-05-10 13:31:45 UTC], ["updated_at", 2016-05-10 13:31:45 UTC]]
|
19
|
+
D, [2016-05-10T16:31:45.901639 #98591] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m
|
@@ -101,6 +101,24 @@ RSpec.describe "Rails integration specs" do
|
|
101
101
|
with(body: /"message":"active_job error"/)
|
102
102
|
).to have_been_made.at_least_once
|
103
103
|
end
|
104
|
+
|
105
|
+
context "when Airbrake is not configured" do
|
106
|
+
it "doesn't report errors" do
|
107
|
+
allow(Airbrake).to receive(:build_notice).and_return(nil)
|
108
|
+
allow(Airbrake).to receive(:notify)
|
109
|
+
|
110
|
+
get '/active_job'
|
111
|
+
sleep 2
|
112
|
+
|
113
|
+
wait_for(
|
114
|
+
a_request(:post, endpoint).
|
115
|
+
with(body: /"message":"active_job error"/)
|
116
|
+
).not_to have_been_made
|
117
|
+
|
118
|
+
expect(Airbrake).to have_received(:build_notice)
|
119
|
+
expect(Airbrake).not_to have_received(:notify)
|
120
|
+
end
|
121
|
+
end
|
104
122
|
end
|
105
123
|
end
|
106
124
|
|
@@ -77,4 +77,17 @@ RSpec.describe Airbrake::Rack::Middleware do
|
|
77
77
|
expect(response[2]).to eq('Bingo bango content')
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
context "when Airbrake is not configured" do
|
82
|
+
it "returns nil" do
|
83
|
+
allow(Airbrake).to receive(:build_notice).and_return(nil)
|
84
|
+
allow(Airbrake).to receive(:notify)
|
85
|
+
|
86
|
+
expect { described_class.new(faulty_app).call(env_for('/')) }.
|
87
|
+
to raise_error(AirbrakeTestError)
|
88
|
+
|
89
|
+
expect(Airbrake).to have_received(:build_notice)
|
90
|
+
expect(Airbrake).not_to have_received(:notify)
|
91
|
+
end
|
92
|
+
end
|
80
93
|
end
|
@@ -79,5 +79,15 @@ RSpec.describe Airbrake::Rack::NoticeBuilder do
|
|
79
79
|
notice = notice_builder.build_notice(AirbrakeTestError.new)
|
80
80
|
expect(notice[:params][:remoteIp]).to eq("127.0.0.1")
|
81
81
|
end
|
82
|
+
|
83
|
+
context "when Airbrake is not configured" do
|
84
|
+
it "returns nil" do
|
85
|
+
allow(Airbrake).to receive(:build_notice).and_return(nil)
|
86
|
+
notice_builder = described_class.new('bingo' => 'bango')
|
87
|
+
|
88
|
+
expect(notice_builder.build_notice('bongo')).to be_nil
|
89
|
+
expect(Airbrake).to have_received(:build_notice)
|
90
|
+
end
|
91
|
+
end
|
82
92
|
end
|
83
93
|
end
|
@@ -32,8 +32,7 @@ RSpec.describe "airbrake/rake/tasks" do
|
|
32
32
|
%w(username john),
|
33
33
|
%w(revision 123abcdef),
|
34
34
|
%w(repository https://github.com/airbrake/airbrake'),
|
35
|
-
%w(version v2.0)
|
36
|
-
].each do |(key, val)|
|
35
|
+
%w(version v2.0)].each do |(key, val)|
|
37
36
|
include_examples 'deploy payload', key, val
|
38
37
|
end
|
39
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Airbrake Technologies, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake-ruby
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.3'
|
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
|
-
version: '1.
|
26
|
+
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- spec/apps/rails/dummy_app.rb
|
189
189
|
- spec/apps/rails/dummy_task.rake
|
190
190
|
- spec/apps/rails/logs/42.log
|
191
|
+
- spec/apps/rails/logs/50.log
|
191
192
|
- spec/apps/sinatra/dummy_app.rb
|
192
193
|
- spec/integration/rack/rack_spec.rb
|
193
194
|
- spec/integration/rails/rails_spec.rb
|
@@ -231,6 +232,7 @@ test_files:
|
|
231
232
|
- spec/apps/rails/dummy_app.rb
|
232
233
|
- spec/apps/rails/dummy_task.rake
|
233
234
|
- spec/apps/rails/logs/42.log
|
235
|
+
- spec/apps/rails/logs/50.log
|
234
236
|
- spec/apps/sinatra/dummy_app.rb
|
235
237
|
- spec/integration/rack/rack_spec.rb
|
236
238
|
- spec/integration/rails/rails_spec.rb
|