airbrake-ruby 4.13.2 → 4.13.4
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.rb +1 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +2 -1
- data/lib/airbrake-ruby/filters/keys_filter.rb +12 -1
- data/lib/airbrake-ruby/stat.rb +15 -10
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/airbrake_spec.rb +10 -0
- data/spec/filters/git_last_checkout_filter_spec.rb +20 -3
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da4c29476df09886ee5e0d9b1b4738cb77a93d9f415c284c57266a64334cf8be
|
4
|
+
data.tar.gz: c12fad300807903f28b3d3dcdc472e729d6e27e74fca597467774c9ea8ab347a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '059b5f84a0ef2c158ead7d0026ff9529c03bdcb8e67d5fb95c8a36465af0bd7510ef8426d7ab644e7d3be9d7884f569d130397ca65854ddd03d34f2c332b30f2'
|
7
|
+
data.tar.gz: 683a8c9d90db59353e70c2f4474825ce583cb8a8d68ff01d895794bd4d6def0daa3ae7898f2ef10398ca24a8361c5fa3d53ae21b270182653431469955b9c578
|
data/lib/airbrake-ruby.rb
CHANGED
@@ -27,6 +27,7 @@ module Airbrake
|
|
27
27
|
@git_path = File.join(root_directory, '.git')
|
28
28
|
@weight = 116
|
29
29
|
@last_checkout = nil
|
30
|
+
@deploy_username = ENV['AIRBRAKE_DEPLOY_USERNAME']
|
30
31
|
end
|
31
32
|
|
32
33
|
# @macro call_filter
|
@@ -59,7 +60,7 @@ module Airbrake
|
|
59
60
|
|
60
61
|
author = parts[2..-4]
|
61
62
|
@last_checkout = {
|
62
|
-
username: author[0..1].join(' '),
|
63
|
+
username: @deploy_username || author[0..1].join(' '),
|
63
64
|
email: parts[-3][1..-2],
|
64
65
|
revision: parts[1],
|
65
66
|
time: timestamp(parts[-2].to_i),
|
@@ -24,7 +24,18 @@ module Airbrake
|
|
24
24
|
|
25
25
|
# @return [Array<Symbol>] parts of a Notice's *context* payload that can
|
26
26
|
# be modified by blacklist/whitelist filters
|
27
|
-
FILTERABLE_CONTEXT_KEYS = %i[
|
27
|
+
FILTERABLE_CONTEXT_KEYS = %i[
|
28
|
+
user
|
29
|
+
|
30
|
+
# Provided by Airbrake::Rack::HttpHeadersFilter
|
31
|
+
headers
|
32
|
+
referer
|
33
|
+
httpMethod
|
34
|
+
|
35
|
+
# Provided by Airbrake::Rack::ContextFilter
|
36
|
+
userAddr
|
37
|
+
userAgent
|
38
|
+
].freeze
|
28
39
|
|
29
40
|
include Loggable
|
30
41
|
|
data/lib/airbrake-ruby/stat.rb
CHANGED
@@ -24,18 +24,21 @@ module Airbrake
|
|
24
24
|
@sum = sum
|
25
25
|
@sumsq = sumsq
|
26
26
|
@tdigest = tdigest
|
27
|
+
@mutex = Mutex.new
|
27
28
|
end
|
28
29
|
|
29
30
|
# @return [Hash{String=>Object}] stats as a hash with compressed TDigest
|
30
31
|
# (serialized as base64)
|
31
32
|
def to_h
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
@mutex.synchronize do
|
34
|
+
tdigest.compress!
|
35
|
+
{
|
36
|
+
'count' => tdigest.size,
|
37
|
+
'sum' => sum,
|
38
|
+
'sumsq' => sumsq,
|
39
|
+
'tdigest' => Base64.strict_encode64(tdigest.as_small_bytes),
|
40
|
+
}
|
41
|
+
end
|
39
42
|
end
|
40
43
|
|
41
44
|
# Increments tdigest timings and updates tdigest with the difference between
|
@@ -54,10 +57,12 @@ module Airbrake
|
|
54
57
|
# @param [Float] ms
|
55
58
|
# @return [void]
|
56
59
|
def increment_ms(ms)
|
57
|
-
|
58
|
-
|
60
|
+
@mutex.synchronize do
|
61
|
+
self.sum += ms
|
62
|
+
self.sumsq += ms * ms
|
59
63
|
|
60
|
-
|
64
|
+
tdigest.push(ms)
|
65
|
+
end
|
61
66
|
end
|
62
67
|
|
63
68
|
# We define custom inspect so that we weed out uninformative TDigest, which
|
data/spec/airbrake_spec.rb
CHANGED
@@ -75,6 +75,16 @@ RSpec.describe Airbrake do
|
|
75
75
|
described_class.configure {}
|
76
76
|
expect(described_class.deploy_notifier).to eql(deploy_notifier)
|
77
77
|
end
|
78
|
+
|
79
|
+
it "doesn't append the same notice notifier filters over and over" do
|
80
|
+
described_class.configure do |c|
|
81
|
+
c.project_id = 1
|
82
|
+
c.project_key = '2'
|
83
|
+
end
|
84
|
+
|
85
|
+
expect(described_class.notice_notifier).not_to receive(:add_filter)
|
86
|
+
10.times { described_class.configure {} }
|
87
|
+
end
|
78
88
|
end
|
79
89
|
|
80
90
|
context "when blacklist_keys gets configured" do
|
@@ -21,24 +21,41 @@ RSpec.describe Airbrake::Filters::GitLastCheckoutFilter do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
context "when .git directory exists" do
|
24
|
-
|
24
|
+
context "when AIRBRAKE_DEPLOY_USERNAME env variable is set" do
|
25
|
+
before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = 'deployer' }
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
it "attaches username from the environment" do
|
28
|
+
subject.call(notice)
|
29
|
+
expect(notice[:context][:lastCheckout][:username]).to eq('deployer')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when AIRBRAKE_DEPLOY_USERNAME env variable is NOT set" do
|
34
|
+
before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = nil }
|
35
|
+
|
36
|
+
it "attaches last checkouted username" do
|
37
|
+
subject.call(notice)
|
38
|
+
username = notice[:context][:lastCheckout][:username]
|
39
|
+
expect(username).not_to be_empty
|
40
|
+
expect(username).not_to be_nil
|
41
|
+
end
|
28
42
|
end
|
29
43
|
|
30
44
|
it "attaches last checkouted email" do
|
45
|
+
subject.call(notice)
|
31
46
|
expect(notice[:context][:lastCheckout][:email]).to(
|
32
47
|
match(/\A\w+[\w.-]*@\w+\.?\w+?\z/),
|
33
48
|
)
|
34
49
|
end
|
35
50
|
|
36
51
|
it "attaches last checkouted revision" do
|
52
|
+
subject.call(notice)
|
37
53
|
expect(notice[:context][:lastCheckout][:revision]).not_to be_empty
|
38
54
|
expect(notice[:context][:lastCheckout][:revision].size).to eq(40)
|
39
55
|
end
|
40
56
|
|
41
57
|
it "attaches last checkouted time" do
|
58
|
+
subject.call(notice)
|
42
59
|
expect(notice[:context][:lastCheckout][:time]).not_to be_empty
|
43
60
|
expect(notice[:context][:lastCheckout][:time].size).to eq(25)
|
44
61
|
end
|
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.13.
|
4
|
+
version: 4.13.4
|
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: 2020-
|
11
|
+
date: 2020-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree3
|
@@ -161,8 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
|
-
|
165
|
-
rubygems_version: 2.7.6.2
|
164
|
+
rubygems_version: 3.1.2
|
166
165
|
signing_key:
|
167
166
|
specification_version: 4
|
168
167
|
summary: Ruby notifier for https://airbrake.io
|