datadog-notifications 0.6.7 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +58 -66
- data/datadog-notifications.gemspec +3 -3
- data/lib/datadog/notifications/config.rb +5 -5
- data/lib/datadog/notifications/version.rb +1 -1
- data/spec/datadog/notifications/config_spec.rb +2 -4
- data/spec/datadog/notifications/plugins/active_job_spec.rb +13 -4
- data/spec/datadog/notifications/plugins/active_record_spec.rb +4 -4
- data/spec/datadog/notifications/plugins/grape_spec.rb +11 -11
- data/spec/datadog/notifications_spec.rb +17 -4
- data/spec/spec_helper.rb +19 -40
- metadata +7 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5935ae5cdf0ad8a0b97044ee63f11b1a7c0c21b4d9d901bff27e14d2d7543b22
|
4
|
+
data.tar.gz: 0aa3de2457df6fb8d23e2ae3ac456cc7c463cc13482851e4e750fa1f1e53a8de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b87c1cd9fc7b2f2f0c4514661b4dd914ef1c529808c6eb1fad0ed1ee20a852b305e96d07b8ca297010495c7d8ae7982cf0cb7e93f8aca75b122d692f4985b415
|
7
|
+
data.tar.gz: 81e36be184535761d78a0e6c1dfd555232b6af6fbd86f6942d00892a5ca63b38377bdef49d60fbd4561794517b583c756bb508aecd34b4dc2e8fc8e9c898e63a
|
data/.github/workflows/ruby.yml
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,42 +1,41 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
datadog-notifications (0.
|
4
|
+
datadog-notifications (0.7.0)
|
5
5
|
activesupport
|
6
|
-
dogstatsd-ruby (>=
|
6
|
+
dogstatsd-ruby (>= 5.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activejob (
|
12
|
-
activesupport (=
|
11
|
+
activejob (7.0.3)
|
12
|
+
activesupport (= 7.0.3)
|
13
13
|
globalid (>= 0.3.6)
|
14
|
-
activemodel (
|
15
|
-
activesupport (=
|
16
|
-
activerecord (
|
17
|
-
activemodel (=
|
18
|
-
activesupport (=
|
19
|
-
activesupport (
|
14
|
+
activemodel (7.0.3)
|
15
|
+
activesupport (= 7.0.3)
|
16
|
+
activerecord (7.0.3)
|
17
|
+
activemodel (= 7.0.3)
|
18
|
+
activesupport (= 7.0.3)
|
19
|
+
activesupport (7.0.3)
|
20
20
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
21
|
i18n (>= 1.6, < 2)
|
22
22
|
minitest (>= 5.1)
|
23
23
|
tzinfo (~> 2.0)
|
24
|
-
zeitwerk (~> 2.3)
|
25
24
|
ast (2.4.2)
|
26
25
|
builder (3.2.4)
|
27
|
-
concurrent-ruby (1.1.
|
28
|
-
diff-lcs (1.
|
29
|
-
dogstatsd-ruby (
|
30
|
-
dry-configurable (0.
|
26
|
+
concurrent-ruby (1.1.10)
|
27
|
+
diff-lcs (1.5.0)
|
28
|
+
dogstatsd-ruby (5.5.0)
|
29
|
+
dry-configurable (0.15.0)
|
31
30
|
concurrent-ruby (~> 1.0)
|
32
|
-
dry-core (~> 0.
|
33
|
-
dry-container (0.
|
31
|
+
dry-core (~> 0.6)
|
32
|
+
dry-container (0.9.0)
|
34
33
|
concurrent-ruby (~> 1.0)
|
35
|
-
dry-configurable (~> 0.
|
36
|
-
dry-core (0.
|
34
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
35
|
+
dry-core (0.7.1)
|
37
36
|
concurrent-ruby (~> 1.0)
|
38
|
-
dry-inflector (0.2.
|
39
|
-
dry-logic (1.
|
37
|
+
dry-inflector (0.2.1)
|
38
|
+
dry-logic (1.2.0)
|
40
39
|
concurrent-ruby (~> 1.0)
|
41
40
|
dry-core (~> 0.5, >= 0.5)
|
42
41
|
dry-types (1.5.1)
|
@@ -45,83 +44,76 @@ GEM
|
|
45
44
|
dry-core (~> 0.5, >= 0.5)
|
46
45
|
dry-inflector (~> 0.1, >= 0.1.2)
|
47
46
|
dry-logic (~> 1.0, >= 1.0.2)
|
48
|
-
globalid (0.
|
49
|
-
activesupport (>=
|
50
|
-
grape (1.
|
47
|
+
globalid (1.0.0)
|
48
|
+
activesupport (>= 5.0)
|
49
|
+
grape (1.6.2)
|
51
50
|
activesupport
|
52
51
|
builder
|
53
52
|
dry-types (>= 1.1)
|
54
53
|
mustermann-grape (~> 1.0.0)
|
55
54
|
rack (>= 1.3.0)
|
56
55
|
rack-accept
|
57
|
-
i18n (1.
|
56
|
+
i18n (1.10.0)
|
58
57
|
concurrent-ruby (~> 1.0)
|
59
|
-
minitest (5.
|
58
|
+
minitest (5.15.0)
|
60
59
|
mustermann (1.1.1)
|
61
60
|
ruby2_keywords (~> 0.0.1)
|
62
|
-
mustermann-grape (1.0.
|
61
|
+
mustermann-grape (1.0.2)
|
63
62
|
mustermann (>= 1.0.0)
|
64
|
-
parallel (1.
|
65
|
-
parser (3.
|
63
|
+
parallel (1.22.1)
|
64
|
+
parser (3.1.2.0)
|
66
65
|
ast (~> 2.4.1)
|
67
|
-
rack (2.2.3)
|
66
|
+
rack (2.2.3.1)
|
68
67
|
rack-accept (0.4.5)
|
69
68
|
rack (>= 0.4)
|
70
69
|
rack-test (1.1.0)
|
71
70
|
rack (>= 1.0, < 3)
|
72
|
-
rainbow (3.
|
73
|
-
rake (13.0.
|
74
|
-
regexp_parser (2.
|
71
|
+
rainbow (3.1.1)
|
72
|
+
rake (13.0.6)
|
73
|
+
regexp_parser (2.5.0)
|
75
74
|
rexml (3.2.5)
|
76
|
-
rspec (3.
|
77
|
-
rspec-core (~> 3.
|
78
|
-
rspec-expectations (~> 3.
|
79
|
-
rspec-mocks (~> 3.
|
80
|
-
rspec-core (3.
|
81
|
-
rspec-support (~> 3.
|
82
|
-
rspec-expectations (3.
|
75
|
+
rspec (3.11.0)
|
76
|
+
rspec-core (~> 3.11.0)
|
77
|
+
rspec-expectations (~> 3.11.0)
|
78
|
+
rspec-mocks (~> 3.11.0)
|
79
|
+
rspec-core (3.11.0)
|
80
|
+
rspec-support (~> 3.11.0)
|
81
|
+
rspec-expectations (3.11.0)
|
83
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
-
rspec-support (~> 3.
|
85
|
-
rspec-mocks (3.
|
83
|
+
rspec-support (~> 3.11.0)
|
84
|
+
rspec-mocks (3.11.1)
|
86
85
|
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
-
rspec-support (~> 3.
|
88
|
-
rspec-support (3.
|
89
|
-
rubocop (1.
|
86
|
+
rspec-support (~> 3.11.0)
|
87
|
+
rspec-support (3.11.0)
|
88
|
+
rubocop (1.30.1)
|
90
89
|
parallel (~> 1.10)
|
91
|
-
parser (>= 3.
|
90
|
+
parser (>= 3.1.0.0)
|
92
91
|
rainbow (>= 2.2.2, < 4.0)
|
93
92
|
regexp_parser (>= 1.8, < 3.0)
|
94
|
-
rexml
|
95
|
-
rubocop-ast (>= 1.
|
93
|
+
rexml (>= 3.2.5, < 4.0)
|
94
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
96
95
|
ruby-progressbar (~> 1.7)
|
97
96
|
unicode-display_width (>= 1.4.0, < 3.0)
|
98
|
-
rubocop-ast (1.
|
99
|
-
parser (>=
|
100
|
-
rubocop-bsm (0.
|
97
|
+
rubocop-ast (1.18.0)
|
98
|
+
parser (>= 3.1.1.0)
|
99
|
+
rubocop-bsm (0.6.0)
|
101
100
|
rubocop (~> 1.0)
|
102
101
|
rubocop-performance
|
103
|
-
rubocop-rails
|
104
102
|
rubocop-rake
|
105
103
|
rubocop-rspec
|
106
|
-
rubocop-performance (1.
|
107
|
-
rubocop (>=
|
104
|
+
rubocop-performance (1.14.1)
|
105
|
+
rubocop (>= 1.7.0, < 2.0)
|
108
106
|
rubocop-ast (>= 0.4.0)
|
109
|
-
rubocop-
|
110
|
-
activesupport (>= 4.2.0)
|
111
|
-
rack (>= 1.1)
|
112
|
-
rubocop (>= 0.90.0, < 2.0)
|
113
|
-
rubocop-rake (0.5.1)
|
114
|
-
rubocop
|
115
|
-
rubocop-rspec (2.2.0)
|
107
|
+
rubocop-rake (0.6.0)
|
116
108
|
rubocop (~> 1.0)
|
117
|
-
|
109
|
+
rubocop-rspec (2.11.1)
|
110
|
+
rubocop (~> 1.19)
|
118
111
|
ruby-progressbar (1.11.0)
|
119
|
-
ruby2_keywords (0.0.
|
112
|
+
ruby2_keywords (0.0.5)
|
120
113
|
sqlite3 (1.4.2)
|
121
114
|
tzinfo (2.0.4)
|
122
115
|
concurrent-ruby (~> 1.0)
|
123
|
-
unicode-display_width (2.
|
124
|
-
zeitwerk (2.4.2)
|
116
|
+
unicode-display_width (2.1.0)
|
125
117
|
|
126
118
|
PLATFORMS
|
127
119
|
ruby
|
@@ -139,4 +131,4 @@ DEPENDENCIES
|
|
139
131
|
sqlite3
|
140
132
|
|
141
133
|
BUNDLED WITH
|
142
|
-
2.
|
134
|
+
2.3.9
|
@@ -12,12 +12,11 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.homepage = 'https://github.com/bsm/datadog-notifications'
|
13
13
|
|
14
14
|
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
15
|
-
s.test_files = s.files.grep(%r{^(spec)/})
|
16
15
|
s.require_paths = ['lib']
|
17
|
-
s.required_ruby_version = '>= 2.
|
16
|
+
s.required_ruby_version = '>= 2.7'
|
18
17
|
|
19
18
|
s.add_runtime_dependency 'activesupport'
|
20
|
-
s.add_runtime_dependency 'dogstatsd-ruby', '>=
|
19
|
+
s.add_runtime_dependency 'dogstatsd-ruby', '>= 5.0'
|
21
20
|
|
22
21
|
s.add_development_dependency 'activejob'
|
23
22
|
s.add_development_dependency 'activerecord'
|
@@ -28,4 +27,5 @@ Gem::Specification.new do |s|
|
|
28
27
|
s.add_development_dependency 'rspec'
|
29
28
|
s.add_development_dependency 'rubocop-bsm'
|
30
29
|
s.add_development_dependency 'sqlite3'
|
30
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
31
31
|
end
|
@@ -4,10 +4,10 @@ module Datadog
|
|
4
4
|
attr_accessor :hostname, :namespace, :tags, :statsd_host, :statsd_port, :reporter, :plugins, :socket_path
|
5
5
|
|
6
6
|
def initialize
|
7
|
-
@hostname = ENV
|
8
|
-
@statsd_host = ENV
|
9
|
-
@statsd_port = ENV
|
10
|
-
@socket_path = ENV
|
7
|
+
@hostname = ENV.fetch('INSTRUMENTATION_HOSTNAME') { Socket.gethostname }
|
8
|
+
@statsd_host = ENV.fetch('STATSD_HOST', nil)
|
9
|
+
@statsd_port = ENV.fetch('STATSD_PORT', nil)
|
10
|
+
@socket_path = ENV.fetch('SOCKET_PATH', nil)
|
11
11
|
@reporter = Datadog::Notifications::Reporter
|
12
12
|
@tags = []
|
13
13
|
@plugins = []
|
@@ -21,7 +21,7 @@ module Datadog
|
|
21
21
|
protected
|
22
22
|
|
23
23
|
def connect!
|
24
|
-
env = ENV
|
24
|
+
env = ENV.fetch('RAILS_ENV') { ENV.fetch('RACK_ENV', nil) }
|
25
25
|
tags.push("env:#{env}") if env && tags.none? {|t| t =~ /^env:/ }
|
26
26
|
|
27
27
|
enable_hostname = hostname && hostname != 'false'
|
@@ -2,23 +2,21 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Datadog::Notifications::Config do
|
4
4
|
it 'is connect!' do
|
5
|
-
subject.reporter = Mock::Reporter
|
6
5
|
subject.hostname = 'test.host'
|
7
6
|
subject.tags = ['custom:tag']
|
8
7
|
|
9
8
|
client = subject.send(:connect!)
|
10
|
-
expect(client).to be_instance_of(
|
9
|
+
expect(client).to be_instance_of(Datadog::Notifications::Reporter)
|
11
10
|
expect(subject.tags).to eq(['custom:tag', 'env:test', 'host:test.host'])
|
12
11
|
end
|
13
12
|
|
14
13
|
RSpec.shared_examples 'host tag is not picked up' do |hostname|
|
15
14
|
it 'does not pick up the host tag' do
|
16
|
-
subject.reporter = Mock::Reporter
|
17
15
|
subject.hostname = hostname
|
18
16
|
subject.tags = ['custom:tag']
|
19
17
|
|
20
18
|
client = subject.send(:connect!)
|
21
|
-
expect(client).to be_instance_of(
|
19
|
+
expect(client).to be_instance_of(Datadog::Notifications::Reporter)
|
22
20
|
expect(subject.tags).to eq(['custom:tag', 'env:test'])
|
23
21
|
end
|
24
22
|
end
|
@@ -2,10 +2,19 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Datadog::Notifications::Plugins::ActiveJob do
|
4
4
|
it 'sanitizes tags' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
klass = Class.new(ActiveJob::Base) do
|
6
|
+
def self.name
|
7
|
+
'Mock::NoopJob'
|
8
|
+
end
|
9
|
+
|
10
|
+
self.queue_name = 'test:queue'
|
11
|
+
def perform; end
|
12
|
+
end
|
13
|
+
|
14
|
+
klass.perform_now
|
15
|
+
expect(messages).to eq [
|
16
|
+
'activejob.perform:1|c|#custom:tag,env:test,host:test.host,job:mock/noop,queue:test_queue',
|
17
|
+
'activejob.perform.time:787.0|ms|#custom:tag,env:test,host:test.host,job:mock/noop,queue:test_queue',
|
9
18
|
]
|
10
19
|
end
|
11
20
|
end
|
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Datadog::Notifications::Plugins::ActiveRecord do
|
4
4
|
it 'sends an increment and timing event for each query' do
|
5
5
|
Post.all.to_a
|
6
|
-
expect(
|
6
|
+
expect(messages).to eq [
|
7
7
|
'activerecord.sql:1|c|#custom:tag,env:test,host:test.host,query:post.load',
|
8
|
-
'activerecord.sql.time:
|
8
|
+
'activerecord.sql.time:111.0|ms|#custom:tag,env:test,host:test.host,query:post.load',
|
9
9
|
]
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'supports custom queries' do
|
13
13
|
Post.find_by_sql('SELECT * FROM posts LIMIT 1').to_a
|
14
|
-
expect(
|
14
|
+
expect(messages).to eq [
|
15
15
|
'activerecord.sql:1|c|#custom:tag,env:test,host:test.host,query:post.load',
|
16
|
-
'activerecord.sql.time:
|
16
|
+
'activerecord.sql.time:111.0|ms|#custom:tag,env:test,host:test.host,query:post.load',
|
17
17
|
]
|
18
18
|
end
|
19
19
|
end
|
@@ -41,9 +41,9 @@ describe Datadog::Notifications::Plugins::Grape do
|
|
41
41
|
expect(last_response.status).to eq(200)
|
42
42
|
expect(last_response.body).to eq('1 1234')
|
43
43
|
|
44
|
-
expect(
|
44
|
+
expect(messages).to eq([
|
45
45
|
'api.request:1|c|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:200,path:/echo/KEY1/KEY2',
|
46
|
-
'api.request.time:
|
46
|
+
'api.request.time:111.0|ms|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:200,path:/echo/KEY1/KEY2',
|
47
47
|
])
|
48
48
|
end
|
49
49
|
|
@@ -52,9 +52,9 @@ describe Datadog::Notifications::Plugins::Grape do
|
|
52
52
|
expect(last_response.status).to eq(200)
|
53
53
|
expect(last_response.body).to eq('OK')
|
54
54
|
|
55
|
-
expect(
|
55
|
+
expect(messages).to eq([
|
56
56
|
'api.request:1|c|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:200,path:/api/sub/versioned,version:v1',
|
57
|
-
'api.request.time:
|
57
|
+
'api.request.time:111.0|ms|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:200,path:/api/sub/versioned,version:v1',
|
58
58
|
])
|
59
59
|
end
|
60
60
|
|
@@ -63,9 +63,9 @@ describe Datadog::Notifications::Plugins::Grape do
|
|
63
63
|
expect(last_response.status).to eq(403)
|
64
64
|
expect(last_response.body).to eq('forbidden')
|
65
65
|
|
66
|
-
expect(
|
66
|
+
expect(messages).to eq([
|
67
67
|
'api.request:1|c|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:403,path:/sub/secure/resource',
|
68
|
-
'api.request.time:
|
68
|
+
'api.request.time:111.0|ms|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:403,path:/sub/secure/resource',
|
69
69
|
])
|
70
70
|
end
|
71
71
|
|
@@ -73,9 +73,9 @@ describe Datadog::Notifications::Plugins::Grape do
|
|
73
73
|
get '/rescued'
|
74
74
|
expect(last_response.status).to eq(401)
|
75
75
|
|
76
|
-
expect(
|
76
|
+
expect(messages).to eq([
|
77
77
|
'api.request:1|c|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:401,path:/rescued',
|
78
|
-
'api.request.time:
|
78
|
+
'api.request.time:111.0|ms|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:401,path:/rescued',
|
79
79
|
])
|
80
80
|
end
|
81
81
|
|
@@ -83,9 +83,9 @@ describe Datadog::Notifications::Plugins::Grape do
|
|
83
83
|
post '/rescued'
|
84
84
|
|
85
85
|
expect(last_response.status).to eq(405)
|
86
|
-
expect(
|
86
|
+
expect(messages).to eq([
|
87
87
|
'api.request:1|c|#custom:tag,env:test,host:test.host,more:tags,method:POST,status:405,path:/rescued',
|
88
|
-
'api.request.time:
|
88
|
+
'api.request.time:111.0|ms|#custom:tag,env:test,host:test.host,more:tags,method:POST,status:405,path:/rescued',
|
89
89
|
])
|
90
90
|
end
|
91
91
|
|
@@ -93,6 +93,6 @@ describe Datadog::Notifications::Plugins::Grape do
|
|
93
93
|
get '/sub/missing'
|
94
94
|
expect(last_response.status).to eq(404)
|
95
95
|
|
96
|
-
expect(
|
96
|
+
expect(messages).to eq([])
|
97
97
|
end
|
98
98
|
end
|
@@ -19,14 +19,27 @@ describe Datadog::Notifications do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'has a reporter' do
|
22
|
-
expect(subject.send(:reporter)).to be_instance_of(
|
22
|
+
expect(subject.send(:reporter)).to be_instance_of(Datadog::Notifications::Reporter)
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'subscribes and report' do
|
26
|
-
|
27
|
-
|
26
|
+
klass = Class.new do
|
27
|
+
def initialize(**opts)
|
28
|
+
@opts = opts
|
29
|
+
end
|
30
|
+
|
31
|
+
def perform
|
32
|
+
ActiveSupport::Notifications.instrument('mock.start', @opts)
|
33
|
+
ActiveSupport::Notifications.instrument('mock.perform', @opts) do |payload|
|
34
|
+
payload[:status] = 200
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
klass.new(method: 'GET').perform
|
39
|
+
|
40
|
+
expect(messages).to eq([
|
28
41
|
'web.render:1|c|#custom:tag,env:test,host:test.host,status:200,method:GET',
|
29
|
-
'web.render.time:
|
42
|
+
'web.render.time:111.0|ms|#custom:tag,env:test,host:test.host,status:200,method:GET',
|
30
43
|
])
|
31
44
|
end
|
32
45
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -19,63 +19,42 @@ end
|
|
19
19
|
class Post < ActiveRecord::Base
|
20
20
|
end
|
21
21
|
|
22
|
-
###
|
22
|
+
### ActiveJob test preparation
|
23
23
|
|
24
24
|
ActiveJob::Base.queue_adapter = :inline
|
25
|
-
class NoopJob < ActiveJob::Base
|
26
|
-
self.queue_name = 'test:queue'
|
27
|
-
def perform; end
|
28
|
-
end
|
29
|
-
|
30
|
-
### Mocks
|
31
|
-
|
32
|
-
module Mock
|
33
|
-
class Reporter < Datadog::Notifications::Reporter
|
34
|
-
def timing(stat, _millis, **opts)
|
35
|
-
super(stat, 333, **opts)
|
36
|
-
end
|
37
|
-
|
38
|
-
def send_stat(message)
|
39
|
-
messages.push message
|
40
|
-
end
|
41
|
-
|
42
|
-
def messages
|
43
|
-
@messages ||= []
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class Instrumentable
|
48
|
-
def initialize(**opts)
|
49
|
-
@opts = opts
|
50
|
-
end
|
51
|
-
|
52
|
-
def perform
|
53
|
-
ActiveSupport::Notifications.instrument('mock.start', @opts)
|
54
|
-
ActiveSupport::Notifications.instrument('mock.perform', @opts) do |payload|
|
55
|
-
payload[:status] = 200
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
25
|
|
61
26
|
### Configuration
|
62
27
|
|
63
28
|
RSpec.configure do |c|
|
64
29
|
helpers = Module.new do
|
65
|
-
def
|
66
|
-
|
30
|
+
def messages
|
31
|
+
@messages ||= []
|
67
32
|
end
|
68
33
|
end
|
69
34
|
|
70
35
|
c.include helpers
|
71
36
|
c.before do
|
72
|
-
|
37
|
+
# clear existing messages
|
38
|
+
messages.clear
|
39
|
+
|
40
|
+
# collect messages
|
41
|
+
reporter = Datadog::Notifications.instance.send(:reporter)
|
42
|
+
forwarder = reporter.send(:forwarder)
|
43
|
+
allow(forwarder).to receive(:send_message) do |msg|
|
44
|
+
@messages.push(msg)
|
45
|
+
end
|
46
|
+
|
47
|
+
# stub Time.now
|
48
|
+
allow(Time).to receive(:now).and_return(
|
49
|
+
Time.at(1616161616.161),
|
50
|
+
Time.at(1616161616.272),
|
51
|
+
Time.at(1616161616.948),
|
52
|
+
)
|
73
53
|
end
|
74
54
|
end
|
75
55
|
|
76
56
|
Datadog::Notifications.configure do |c|
|
77
57
|
c.hostname = 'test.host'
|
78
|
-
c.reporter = Mock::Reporter
|
79
58
|
c.tags = ['custom:tag']
|
80
59
|
|
81
60
|
c.use Datadog::Notifications::Plugins::ActiveRecord
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datadog-notifications
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitrij Denissenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -29,9 +29,6 @@ dependencies:
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '4.8'
|
34
|
-
- - "<"
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: '5.0'
|
37
34
|
type: :runtime
|
@@ -39,9 +36,6 @@ dependencies:
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '4.8'
|
44
|
-
- - "<"
|
45
39
|
- !ruby/object:Gem::Version
|
46
40
|
version: '5.0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
@@ -207,7 +201,8 @@ files:
|
|
207
201
|
- spec/spec_helper.rb
|
208
202
|
homepage: https://github.com/bsm/datadog-notifications
|
209
203
|
licenses: []
|
210
|
-
metadata:
|
204
|
+
metadata:
|
205
|
+
rubygems_mfa_required: 'true'
|
211
206
|
post_install_message:
|
212
207
|
rdoc_options: []
|
213
208
|
require_paths:
|
@@ -216,21 +211,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
211
|
requirements:
|
217
212
|
- - ">="
|
218
213
|
- !ruby/object:Gem::Version
|
219
|
-
version: '2.
|
214
|
+
version: '2.7'
|
220
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
216
|
requirements:
|
222
217
|
- - ">="
|
223
218
|
- !ruby/object:Gem::Version
|
224
219
|
version: '0'
|
225
220
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
221
|
+
rubygems_version: 3.3.7
|
227
222
|
signing_key:
|
228
223
|
specification_version: 4
|
229
224
|
summary: Generic ActiveSupport::Notifications Datadog handler
|
230
|
-
test_files:
|
231
|
-
- spec/datadog/notifications/config_spec.rb
|
232
|
-
- spec/datadog/notifications/plugins/active_job_spec.rb
|
233
|
-
- spec/datadog/notifications/plugins/active_record_spec.rb
|
234
|
-
- spec/datadog/notifications/plugins/grape_spec.rb
|
235
|
-
- spec/datadog/notifications_spec.rb
|
236
|
-
- spec/spec_helper.rb
|
225
|
+
test_files: []
|