airbrake-ruby 3.0.0.rc.8 → 3.0.0.rc.9
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/lib/airbrake-ruby/config.rb +9 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +2 -0
- data/lib/airbrake-ruby/notifier.rb +11 -1
- data/lib/airbrake-ruby/route_sender.rb +3 -3
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/config_spec.rb +4 -0
- data/spec/filters/git_last_checkout_filter_spec.rb +3 -1
- data/spec/notifier_spec.rb +26 -3
- data/spec/route_sender_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8f0a23f9d134d54cd586ca311b27cf82d0c3e8
|
4
|
+
data.tar.gz: 06d0f6fbf5b7f7809b0df03806e9991c564eb018
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9a326402201a26169bd1c65d36e049ebbfdb5ebf27c314e8dd803e30da89366ac0e8e897cebddf6112fdb751fabc6421e0e4aafea8bf65b5201672aaf731b8c
|
7
|
+
data.tar.gz: 4648f252843e74ad697e519769126acdc3d007ea00316eaf694c7a672c3ffff87272d0e1278e80d7ccd7dca828834104c93e2b179064d462a3c3e3a1652b9f94
|
data/lib/airbrake-ruby/config.rb
CHANGED
@@ -83,6 +83,12 @@ module Airbrake
|
|
83
83
|
# @since v2.5.0
|
84
84
|
attr_accessor :code_hunks
|
85
85
|
|
86
|
+
# @return [Boolean] true if the library should send route stats information
|
87
|
+
# to Airbrake, false otherwise
|
88
|
+
# @api public
|
89
|
+
# @since v3.0.0
|
90
|
+
attr_accessor :route_stats
|
91
|
+
|
86
92
|
# @return [Integer] how many seconds to wait before sending collected route
|
87
93
|
# stats
|
88
94
|
# @api public
|
@@ -91,6 +97,7 @@ module Airbrake
|
|
91
97
|
|
92
98
|
# @param [Hash{Symbol=>Object}] user_config the hash to be used to build the
|
93
99
|
# config
|
100
|
+
# rubocop:disable Metrics/AbcSize
|
94
101
|
def initialize(user_config = {})
|
95
102
|
@validator = Config::Validator.new(self)
|
96
103
|
|
@@ -119,10 +126,12 @@ module Airbrake
|
|
119
126
|
)
|
120
127
|
|
121
128
|
self.versions = {}
|
129
|
+
self.route_stats = true
|
122
130
|
self.route_stats_flush_period = 15
|
123
131
|
|
124
132
|
merge(user_config)
|
125
133
|
end
|
134
|
+
# rubocop:enable Metrics/AbcSize
|
126
135
|
|
127
136
|
# The full URL to the Airbrake Notice API. Based on the +:host+ option.
|
128
137
|
# @return [URI] the endpoint address
|
@@ -101,7 +101,17 @@ module Airbrake
|
|
101
101
|
|
102
102
|
# @macro see_public_api_method
|
103
103
|
def notify_request(request_info)
|
104
|
-
|
104
|
+
promise = Airbrake::Promise.new
|
105
|
+
|
106
|
+
if @config.ignored_environment?
|
107
|
+
return promise.reject("The '#{@config.environment}' environment is ignored")
|
108
|
+
end
|
109
|
+
|
110
|
+
unless @config.route_stats
|
111
|
+
return promise.reject("The Route Stats feature is disabled")
|
112
|
+
end
|
113
|
+
|
114
|
+
@route_sender.notify_request(request_info, promise)
|
105
115
|
end
|
106
116
|
|
107
117
|
# @return [String] customized inspect to lessen the amount of clutter
|
@@ -49,7 +49,7 @@ module Airbrake
|
|
49
49
|
using TDigestBigEndianness
|
50
50
|
|
51
51
|
# The key that represents a route.
|
52
|
-
RouteKey = Struct.new(:method, :route, :
|
52
|
+
RouteKey = Struct.new(:method, :route, :statusCode, :time)
|
53
53
|
|
54
54
|
# RouteStat holds data that describes a route's performance.
|
55
55
|
RouteStat = Struct.new(:count, :sum, :sumsq, :tdigest) do
|
@@ -87,14 +87,14 @@ module Airbrake
|
|
87
87
|
end
|
88
88
|
|
89
89
|
# @macro see_public_api_method
|
90
|
-
|
90
|
+
# @param [Airbrake::Promise] promise
|
91
|
+
def notify_request(request_info, promise = Airbrake::Promise.new)
|
91
92
|
route = create_route_key(
|
92
93
|
request_info[:method],
|
93
94
|
request_info[:route],
|
94
95
|
request_info[:status_code],
|
95
96
|
utc_truncate_minutes(request_info[:start_time])
|
96
97
|
)
|
97
|
-
promise = Airbrake::Promise.new
|
98
98
|
|
99
99
|
@mutex.synchronize do
|
100
100
|
@routes[route] ||= RouteStat.new
|
data/spec/config_spec.rb
CHANGED
@@ -79,6 +79,10 @@ RSpec.describe Airbrake::Config do
|
|
79
79
|
expect(config.whitelist_keys).to be_empty
|
80
80
|
end
|
81
81
|
|
82
|
+
it "enables route stats by default" do
|
83
|
+
expect(config.route_stats).to be_truthy
|
84
|
+
end
|
85
|
+
|
82
86
|
it "sets the default route_stats_flush_period" do
|
83
87
|
expect(config.route_stats_flush_period).to eq(15)
|
84
88
|
end
|
@@ -32,7 +32,9 @@ RSpec.describe Airbrake::Filters::GitLastCheckoutFilter do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "attaches last checkouted email" do
|
35
|
-
expect(notice[:context][:lastCheckout][:email]).to
|
35
|
+
expect(notice[:context][:lastCheckout][:email]).to(
|
36
|
+
match(/\A\w+[\w.-]*@\w+\.?\w+?\z/)
|
37
|
+
)
|
36
38
|
end
|
37
39
|
|
38
40
|
it "attaches last checkouted revision" do
|
data/spec/notifier_spec.rb
CHANGED
@@ -451,18 +451,41 @@ RSpec.describe Airbrake::Notifier do
|
|
451
451
|
end
|
452
452
|
|
453
453
|
describe "#notify_request" do
|
454
|
-
|
455
|
-
|
454
|
+
let(:params) do
|
455
|
+
{
|
456
456
|
method: 'GET',
|
457
457
|
route: '/foo',
|
458
458
|
status_code: 200,
|
459
459
|
start_time: Time.new(2018, 1, 1, 0, 20, 0, 0),
|
460
460
|
end_time: Time.new(2018, 1, 1, 0, 19, 0, 0)
|
461
461
|
}
|
462
|
+
end
|
463
|
+
|
464
|
+
it "forwards 'notify_request' to RouteSender" do
|
462
465
|
expect_any_instance_of(Airbrake::RouteSender)
|
463
|
-
.to receive(:notify_request).with(params)
|
466
|
+
.to receive(:notify_request).with(params, instance_of(Airbrake::Promise))
|
464
467
|
subject.notify_request(params)
|
465
468
|
end
|
469
|
+
|
470
|
+
context "when route stats are disabled" do
|
471
|
+
it "doesn't send route stats" do
|
472
|
+
notifier = described_class.new(user_params.merge(route_stats: false))
|
473
|
+
expect_any_instance_of(Airbrake::RouteSender)
|
474
|
+
.not_to receive(:notify_request)
|
475
|
+
notifier.notify_request(params)
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
context "when current environment is ignored" do
|
480
|
+
it "doesn't send route stats" do
|
481
|
+
notifier = described_class.new(
|
482
|
+
user_params.merge(environment: 'test', ignore_environments: %w[test])
|
483
|
+
)
|
484
|
+
expect_any_instance_of(Airbrake::RouteSender)
|
485
|
+
.not_to receive(:notify_request)
|
486
|
+
notifier.notify_request(params)
|
487
|
+
end
|
488
|
+
end
|
466
489
|
end
|
467
490
|
|
468
491
|
describe "#inspect" do
|
data/spec/route_sender_spec.rb
CHANGED
@@ -73,10 +73,10 @@ RSpec.describe Airbrake::RouteSender do
|
|
73
73
|
a_request(:put, endpoint).with(
|
74
74
|
body: %r|\A
|
75
75
|
{"routes":\[
|
76
|
-
{"method":"GET","route":"/foo","
|
76
|
+
{"method":"GET","route":"/foo","statusCode":200,
|
77
77
|
"time":"2018-01-01T00:00:00\+00:00","count":1,"sum":1000.0,
|
78
78
|
"sumsq":1000000.0,"tdigest":"AAAAAkA0AAAAAAAAAAAAAUR6AAAB"},
|
79
|
-
{"method":"GET","route":"/foo","
|
79
|
+
{"method":"GET","route":"/foo","statusCode":200,
|
80
80
|
"time":"2018-01-01T00:01:00\+00:00","count":1,"sum":6000.0,
|
81
81
|
"sumsq":36000000.0,"tdigest":"AAAAAkA0AAAAAAAAAAAAAUW7gAAB"}\]}
|
82
82
|
\z|x
|
@@ -104,10 +104,10 @@ RSpec.describe Airbrake::RouteSender do
|
|
104
104
|
a_request(:put, endpoint).with(
|
105
105
|
body: %r|\A
|
106
106
|
{"routes":\[
|
107
|
-
{"method":"GET","route":"/foo","
|
107
|
+
{"method":"GET","route":"/foo","statusCode":200,
|
108
108
|
"time":"2018-01-01T00:49:00\+00:00","count":1,"sum":60000.0,
|
109
109
|
"sumsq":3600000000.0,"tdigest":"AAAAAkA0AAAAAAAAAAAAAUdqYAAB"},
|
110
|
-
{"method":"POST","route":"/foo","
|
110
|
+
{"method":"POST","route":"/foo","statusCode":200,
|
111
111
|
"time":"2018-01-01T00:49:00\+00:00","count":1,"sum":60000.0,
|
112
112
|
"sumsq":3600000000.0,"tdigest":"AAAAAkA0AAAAAAAAAAAAAUdqYAAB"}\]}
|
113
113
|
\z|x
|
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: 3.0.0.rc.
|
4
|
+
version: 3.0.0.rc.9
|
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: 2018-
|
11
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tdigest
|