airbrake-ruby 4.2.3-java → 4.2.4-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby/benchmark.rb +14 -0
- data/lib/airbrake-ruby/monotonic_time.rb +43 -0
- data/lib/airbrake-ruby/notice_notifier.rb +4 -31
- data/lib/airbrake-ruby/version.rb +1 -1
- data/lib/airbrake-ruby.rb +48 -13
- data/spec/airbrake_spec.rb +82 -0
- data/spec/benchmark_spec.rb +7 -0
- data/spec/monotonic_time_spec.rb +12 -0
- data/spec/notice_notifier_spec/options_spec.rb +3 -1
- data/spec/notice_notifier_spec.rb +0 -56
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95d28a9be05212c519e1626767a363c09dedb9b4
|
4
|
+
data.tar.gz: 7f423d7dc6a3d470d3309a6b2443c94166b0e622
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1bb40a3498c6d48b13aa665152d9235a23edc20416468eedd46862841d00e5db4a059cda730dc80d4681e2ec890e12060db8ce0239e8de36618514956b98d24
|
7
|
+
data.tar.gz: a688273b29302a1c6b831f33f9a76afa2bdad6d399e3defd2f43b737e6e81defbc0ebd7322098a7db9e98111505ebb64cd22912041f051adf2b4eb05bcb7ba81
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Airbrake
|
2
|
+
# Benchmark benchmarks Ruby code.
|
3
|
+
#
|
4
|
+
# @since v4.3.0
|
5
|
+
# @api private
|
6
|
+
module Benchmark
|
7
|
+
# Measures monotonic time for the given operation.
|
8
|
+
def self.measure
|
9
|
+
start = MonotonicTime.time_in_ms
|
10
|
+
yield
|
11
|
+
MonotonicTime.time_in_ms - start
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Airbrake
|
2
|
+
# MonotonicTime is a helper for getting monotonic time suitable for
|
3
|
+
# performance measurements. It guarantees that the time is strictly linearly
|
4
|
+
# increasing (unlike realtime).
|
5
|
+
#
|
6
|
+
# @example
|
7
|
+
# MonotonicTime.time_in_ms #=> 287138801.144576
|
8
|
+
#
|
9
|
+
# @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
|
10
|
+
# @since v4.3.0
|
11
|
+
# @api private
|
12
|
+
module MonotonicTime
|
13
|
+
class << self
|
14
|
+
# @return [Integer] current monotonic time in milliseconds
|
15
|
+
def time_in_ms
|
16
|
+
time_in_nanoseconds / (10.0**6)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
if defined?(Process::CLOCK_MONOTONIC)
|
22
|
+
|
23
|
+
def time_in_nanoseconds
|
24
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
|
25
|
+
end
|
26
|
+
|
27
|
+
elsif RUBY_ENGINE == 'jruby'
|
28
|
+
|
29
|
+
def time_in_nanoseconds
|
30
|
+
java.lang.System.nanoTime
|
31
|
+
end
|
32
|
+
|
33
|
+
else
|
34
|
+
|
35
|
+
def time_in_nanoseconds
|
36
|
+
time = Time.now
|
37
|
+
time.to_i * (10**9) + time.nsec
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -25,7 +25,10 @@ module Airbrake
|
|
25
25
|
@async_sender = AsyncSender.new
|
26
26
|
@sync_sender = SyncSender.new
|
27
27
|
|
28
|
-
|
28
|
+
DEFAULT_FILTERS.each { |filter| add_filter(filter.new) }
|
29
|
+
|
30
|
+
add_filter(Airbrake::Filters::ContextFilter.new(@context))
|
31
|
+
add_filter(Airbrake::Filters::ExceptionAttributesFilter.new)
|
29
32
|
end
|
30
33
|
|
31
34
|
# @macro see_public_api_method
|
@@ -127,35 +130,5 @@ module Airbrake
|
|
127
130
|
return caller_copy if clean_bt.empty?
|
128
131
|
clean_bt
|
129
132
|
end
|
130
|
-
|
131
|
-
# rubocop:disable Metrics/AbcSize
|
132
|
-
def add_default_filters
|
133
|
-
DEFAULT_FILTERS.each { |f| add_filter(f.new) }
|
134
|
-
|
135
|
-
if (whitelist_keys = @config.whitelist_keys).any?
|
136
|
-
add_filter(Airbrake::Filters::KeysWhitelist.new(whitelist_keys))
|
137
|
-
end
|
138
|
-
|
139
|
-
if (blacklist_keys = @config.blacklist_keys).any?
|
140
|
-
add_filter(Airbrake::Filters::KeysBlacklist.new(blacklist_keys))
|
141
|
-
end
|
142
|
-
|
143
|
-
add_filter(Airbrake::Filters::ContextFilter.new(@context))
|
144
|
-
add_filter(Airbrake::Filters::ExceptionAttributesFilter.new)
|
145
|
-
|
146
|
-
return unless (root_directory = @config.root_directory)
|
147
|
-
[
|
148
|
-
Airbrake::Filters::RootDirectoryFilter,
|
149
|
-
Airbrake::Filters::GitRevisionFilter,
|
150
|
-
Airbrake::Filters::GitRepositoryFilter
|
151
|
-
].each do |filter|
|
152
|
-
add_filter(filter.new(root_directory))
|
153
|
-
end
|
154
|
-
|
155
|
-
add_filter(
|
156
|
-
Airbrake::Filters::GitLastCheckoutFilter.new(root_directory)
|
157
|
-
)
|
158
|
-
end
|
159
|
-
# rubocop:enable Metrics/AbcSize
|
160
133
|
end
|
161
134
|
end
|
data/lib/airbrake-ruby.rb
CHANGED
@@ -47,6 +47,8 @@ require 'airbrake-ruby/tdigest'
|
|
47
47
|
require 'airbrake-ruby/query'
|
48
48
|
require 'airbrake-ruby/request'
|
49
49
|
require 'airbrake-ruby/performance_breakdown'
|
50
|
+
require 'airbrake-ruby/benchmark'
|
51
|
+
require 'airbrake-ruby/monotonic_time'
|
50
52
|
|
51
53
|
# Airbrake is a thin wrapper around instances of the notifier classes (such as
|
52
54
|
# notice, performance & deploy notifiers). It creates a way to access them via a
|
@@ -81,15 +83,15 @@ module Airbrake
|
|
81
83
|
class << self
|
82
84
|
# @since v4.2.3
|
83
85
|
# @api private
|
84
|
-
|
86
|
+
attr_writer :performance_notifier
|
85
87
|
|
86
88
|
# @since v4.2.3
|
87
89
|
# @api private
|
88
|
-
|
90
|
+
attr_writer :notice_notifier
|
89
91
|
|
90
92
|
# @since v4.2.3
|
91
93
|
# @api private
|
92
|
-
|
94
|
+
attr_writer :deploy_notifier
|
93
95
|
|
94
96
|
# Configures the Airbrake notifier.
|
95
97
|
#
|
@@ -99,19 +101,31 @@ module Airbrake
|
|
99
101
|
# c.project_key = 'fd04e13d806a90f96614ad8e529b2822'
|
100
102
|
# end
|
101
103
|
#
|
102
|
-
# @yield [config]
|
104
|
+
# @yield [config]
|
103
105
|
# @yieldparam config [Airbrake::Config]
|
104
106
|
# @return [void]
|
105
|
-
# @raise [Airbrake::Error] when trying to reconfigure already
|
106
|
-
# existing notifier
|
107
|
-
# @note There's no way to read config values outside of this library
|
108
107
|
def configure
|
109
108
|
yield config = Airbrake::Config.instance
|
110
109
|
Airbrake::Loggable.instance = config.logger
|
110
|
+
process_config_options(config)
|
111
|
+
end
|
111
112
|
|
112
|
-
|
113
|
+
# @since v4.2.3
|
114
|
+
# @api private
|
115
|
+
def performance_notifier
|
116
|
+
@performance_notifier ||= NoticeNotifier.new
|
117
|
+
end
|
113
118
|
|
114
|
-
|
119
|
+
# @since v4.2.3
|
120
|
+
# @api private
|
121
|
+
def notice_notifier
|
122
|
+
@notice_notifier ||= NoticeNotifier.new
|
123
|
+
end
|
124
|
+
|
125
|
+
# @since v4.2.3
|
126
|
+
# @api private
|
127
|
+
def deploy_notifier
|
128
|
+
@deploy_notifier ||= PerformanceNotifier.new
|
115
129
|
end
|
116
130
|
|
117
131
|
# @return [Boolean] true if the notifier was configured, false otherwise
|
@@ -459,9 +473,30 @@ module Airbrake
|
|
459
473
|
self.notice_notifier = NoticeNotifier.new
|
460
474
|
self.deploy_notifier = DeployNotifier.new
|
461
475
|
end
|
462
|
-
end
|
463
|
-
end
|
464
476
|
|
465
|
-
|
466
|
-
|
477
|
+
private
|
478
|
+
|
479
|
+
def process_config_options(config)
|
480
|
+
if config.blacklist_keys.any?
|
481
|
+
blacklist = Airbrake::Filters::KeysBlacklist.new(config.blacklist_keys)
|
482
|
+
notice_notifier.add_filter(blacklist)
|
483
|
+
end
|
484
|
+
|
485
|
+
if config.whitelist_keys.any?
|
486
|
+
whitelist = Airbrake::Filters::KeysWhitelist.new(config.whitelist_keys)
|
487
|
+
notice_notifier.add_filter(whitelist)
|
488
|
+
end
|
489
|
+
|
490
|
+
return unless config.root_directory
|
491
|
+
|
492
|
+
[
|
493
|
+
Airbrake::Filters::RootDirectoryFilter,
|
494
|
+
Airbrake::Filters::GitRevisionFilter,
|
495
|
+
Airbrake::Filters::GitRepositoryFilter,
|
496
|
+
Airbrake::Filters::GitLastCheckoutFilter
|
497
|
+
].each do |filter|
|
498
|
+
notice_notifier.add_filter(filter.new(config.root_directory))
|
499
|
+
end
|
500
|
+
end
|
501
|
+
end
|
467
502
|
end
|
data/spec/airbrake_spec.rb
CHANGED
@@ -98,6 +98,88 @@ RSpec.describe Airbrake do
|
|
98
98
|
expect(described_class.deploy_notifier).to eql(deploy_notifier)
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
context "when blacklist_keys gets configured" do
|
103
|
+
before { allow(Airbrake.notice_notifier).to receive(:add_filter) }
|
104
|
+
|
105
|
+
it "adds blacklist filter" do
|
106
|
+
expect(Airbrake.notice_notifier).to receive(:add_filter)
|
107
|
+
.with(an_instance_of(Airbrake::Filters::KeysBlacklist))
|
108
|
+
described_class.configure { |c| c.blacklist_keys = %w[password] }
|
109
|
+
end
|
110
|
+
|
111
|
+
it "initializes blacklist with specified parameters" do
|
112
|
+
expect(Airbrake::Filters::KeysBlacklist).to receive(:new).with(%w[password])
|
113
|
+
described_class.configure { |c| c.blacklist_keys = %w[password] }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "when whitelist_keys gets configured" do
|
118
|
+
before { allow(Airbrake.notice_notifier).to receive(:add_filter) }
|
119
|
+
|
120
|
+
it "adds whitelist filter" do
|
121
|
+
expect(Airbrake.notice_notifier).to receive(:add_filter)
|
122
|
+
.with(an_instance_of(Airbrake::Filters::KeysWhitelist))
|
123
|
+
described_class.configure { |c| c.whitelist_keys = %w[banana] }
|
124
|
+
end
|
125
|
+
|
126
|
+
it "initializes whitelist with specified parameters" do
|
127
|
+
expect(Airbrake::Filters::KeysWhitelist).to receive(:new).with(%w[banana])
|
128
|
+
described_class.configure { |c| c.whitelist_keys = %w[banana] }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "when root_directory gets configured" do
|
133
|
+
before { allow(Airbrake.notice_notifier).to receive(:add_filter) }
|
134
|
+
|
135
|
+
it "adds root directory filter" do
|
136
|
+
expect(Airbrake.notice_notifier).to receive(:add_filter)
|
137
|
+
.with(an_instance_of(Airbrake::Filters::RootDirectoryFilter))
|
138
|
+
described_class.configure { |c| c.root_directory = '/my/path' }
|
139
|
+
end
|
140
|
+
|
141
|
+
it "initializes root directory filter with specified path" do
|
142
|
+
expect(Airbrake::Filters::RootDirectoryFilter)
|
143
|
+
.to receive(:new).with('/my/path')
|
144
|
+
described_class.configure { |c| c.root_directory = '/my/path' }
|
145
|
+
end
|
146
|
+
|
147
|
+
it "adds git revision filter" do
|
148
|
+
expect(Airbrake.notice_notifier).to receive(:add_filter)
|
149
|
+
.with(an_instance_of(Airbrake::Filters::GitRevisionFilter))
|
150
|
+
described_class.configure { |c| c.root_directory = '/my/path' }
|
151
|
+
end
|
152
|
+
|
153
|
+
it "initializes git revision filter with correct root directory" do
|
154
|
+
expect(Airbrake::Filters::GitRevisionFilter)
|
155
|
+
.to receive(:new).with('/my/path')
|
156
|
+
described_class.configure { |c| c.root_directory = '/my/path' }
|
157
|
+
end
|
158
|
+
|
159
|
+
it "adds git repository filter" do
|
160
|
+
expect(Airbrake.notice_notifier).to receive(:add_filter)
|
161
|
+
.with(an_instance_of(Airbrake::Filters::GitRepositoryFilter))
|
162
|
+
described_class.configure { |c| c.root_directory = '/my/path' }
|
163
|
+
end
|
164
|
+
|
165
|
+
it "initializes git repository filter with correct root directory" do
|
166
|
+
expect(Airbrake::Filters::GitRepositoryFilter)
|
167
|
+
.to receive(:new).with('/my/path')
|
168
|
+
described_class.configure { |c| c.root_directory = '/my/path' }
|
169
|
+
end
|
170
|
+
|
171
|
+
it "adds git last checkout filter" do
|
172
|
+
expect(Airbrake.notice_notifier).to receive(:add_filter)
|
173
|
+
.with(an_instance_of(Airbrake::Filters::GitLastCheckoutFilter))
|
174
|
+
described_class.configure { |c| c.root_directory = '/my/path' }
|
175
|
+
end
|
176
|
+
|
177
|
+
it "initializes git last checkout filter with correct root directory" do
|
178
|
+
expect(Airbrake::Filters::GitLastCheckoutFilter)
|
179
|
+
.to receive(:new).with('/my/path')
|
180
|
+
described_class.configure { |c| c.root_directory = '/my/path' }
|
181
|
+
end
|
182
|
+
end
|
101
183
|
end
|
102
184
|
|
103
185
|
describe "#reset" do
|
@@ -0,0 +1,12 @@
|
|
1
|
+
RSpec.describe Airbrake::MonotonicTime do
|
2
|
+
describe ".time_in_ms" do
|
3
|
+
it "returns monotonic time in milliseconds" do
|
4
|
+
expect(subject.time_in_ms).to be_a(Float)
|
5
|
+
end
|
6
|
+
|
7
|
+
it "always returns time in the future" do
|
8
|
+
old_time = subject.time_in_ms
|
9
|
+
expect(subject.time_in_ms).to be > old_time
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -63,7 +63,9 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
63
63
|
|
64
64
|
describe ":root_directory" do
|
65
65
|
before do
|
66
|
-
|
66
|
+
subject.add_filter(
|
67
|
+
Airbrake::Filters::RootDirectoryFilter.new('/home/kyrylo/code')
|
68
|
+
)
|
67
69
|
end
|
68
70
|
|
69
71
|
it "filters out frames" do
|
@@ -23,62 +23,6 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
23
23
|
.with(instance_of(Airbrake::Filters::ExceptionAttributesFilter))
|
24
24
|
subject
|
25
25
|
end
|
26
|
-
|
27
|
-
context "when user config has some whitelist keys" do
|
28
|
-
before { Airbrake::Config.instance.merge(whitelist_keys: %w[foo]) }
|
29
|
-
|
30
|
-
it "appends the whitelist filter" do
|
31
|
-
expect_any_instance_of(Airbrake::FilterChain).to receive(:add_filter)
|
32
|
-
.with(instance_of(Airbrake::Filters::KeysWhitelist))
|
33
|
-
subject
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when user config doesn't have any whitelist keys" do
|
38
|
-
it "doesn't append the whitelist filter" do
|
39
|
-
expect_any_instance_of(Airbrake::FilterChain).not_to receive(:add_filter)
|
40
|
-
.with(instance_of(Airbrake::Filters::KeysWhitelist))
|
41
|
-
subject
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "when user config has some blacklist keys" do
|
46
|
-
before { Airbrake::Config.instance.merge(blacklist_keys: %w[bar]) }
|
47
|
-
|
48
|
-
it "appends the blacklist filter" do
|
49
|
-
expect_any_instance_of(Airbrake::FilterChain).to receive(:add_filter)
|
50
|
-
.with(instance_of(Airbrake::Filters::KeysBlacklist))
|
51
|
-
subject
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "when user config doesn't have any blacklist keys" do
|
56
|
-
it "doesn't append the blacklist filter" do
|
57
|
-
expect_any_instance_of(Airbrake::FilterChain).not_to receive(:add_filter)
|
58
|
-
.with(instance_of(Airbrake::Filters::KeysBlacklist))
|
59
|
-
subject
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context "when user config specifies a root directory" do
|
64
|
-
before { Airbrake::Config.instance.merge(root_directory: '/foo') }
|
65
|
-
|
66
|
-
it "appends the root directory filter" do
|
67
|
-
expect_any_instance_of(Airbrake::FilterChain).to receive(:add_filter)
|
68
|
-
.with(instance_of(Airbrake::Filters::RootDirectoryFilter))
|
69
|
-
subject
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "when user config doesn't specify a root directory" do
|
74
|
-
it "doesn't append the root directory filter" do
|
75
|
-
expect_any_instance_of(Airbrake::Config).to receive(:root_directory)
|
76
|
-
.and_return(nil)
|
77
|
-
expect_any_instance_of(Airbrake::FilterChain).not_to receive(:add_filter)
|
78
|
-
.with(instance_of(Airbrake::Filters::RootDirectoryFilter))
|
79
|
-
subject
|
80
|
-
end
|
81
|
-
end
|
82
26
|
end
|
83
27
|
end
|
84
28
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrake-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.4
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Airbrake Technologies, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree-jruby
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- lib/airbrake-ruby.rb
|
42
42
|
- lib/airbrake-ruby/async_sender.rb
|
43
43
|
- lib/airbrake-ruby/backtrace.rb
|
44
|
+
- lib/airbrake-ruby/benchmark.rb
|
44
45
|
- lib/airbrake-ruby/code_hunk.rb
|
45
46
|
- lib/airbrake-ruby/config.rb
|
46
47
|
- lib/airbrake-ruby/config/validator.rb
|
@@ -65,6 +66,7 @@ files:
|
|
65
66
|
- lib/airbrake-ruby/ignorable.rb
|
66
67
|
- lib/airbrake-ruby/inspectable.rb
|
67
68
|
- lib/airbrake-ruby/loggable.rb
|
69
|
+
- lib/airbrake-ruby/monotonic_time.rb
|
68
70
|
- lib/airbrake-ruby/nested_exception.rb
|
69
71
|
- lib/airbrake-ruby/notice.rb
|
70
72
|
- lib/airbrake-ruby/notice_notifier.rb
|
@@ -83,6 +85,7 @@ files:
|
|
83
85
|
- spec/airbrake_spec.rb
|
84
86
|
- spec/async_sender_spec.rb
|
85
87
|
- spec/backtrace_spec.rb
|
88
|
+
- spec/benchmark_spec.rb
|
86
89
|
- spec/code_hunk_spec.rb
|
87
90
|
- spec/config/validator_spec.rb
|
88
91
|
- spec/config_spec.rb
|
@@ -111,6 +114,7 @@ files:
|
|
111
114
|
- spec/helpers.rb
|
112
115
|
- spec/ignorable_spec.rb
|
113
116
|
- spec/inspectable_spec.rb
|
117
|
+
- spec/monotonic_time_spec.rb
|
114
118
|
- spec/nested_exception_spec.rb
|
115
119
|
- spec/notice_notifier_spec.rb
|
116
120
|
- spec/notice_notifier_spec/options_spec.rb
|
@@ -150,6 +154,7 @@ specification_version: 4
|
|
150
154
|
summary: Ruby notifier for https://airbrake.io
|
151
155
|
test_files:
|
152
156
|
- spec/truncator_spec.rb
|
157
|
+
- spec/benchmark_spec.rb
|
153
158
|
- spec/helpers.rb
|
154
159
|
- spec/filters/exception_attributes_filter_spec.rb
|
155
160
|
- spec/filters/root_directory_filter_spec.rb
|
@@ -191,5 +196,6 @@ test_files:
|
|
191
196
|
- spec/fixtures/project_root/code.rb
|
192
197
|
- spec/fixtures/project_root/short_file.rb
|
193
198
|
- spec/fixtures/project_root/vendor/bundle/ignored_file.rb
|
199
|
+
- spec/monotonic_time_spec.rb
|
194
200
|
- spec/inspectable_spec.rb
|
195
201
|
- spec/notice_notifier_spec/options_spec.rb
|