datadog-notifications 0.6.7 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fe55c10d1c135748c2a818187431d0f316a8cf0192cefdf7ab45d6245e6add9
4
- data.tar.gz: f9449725f5768bb0e75eb02363f12eda4235e474d7fb00e6f7cc4c2b54c599d2
3
+ metadata.gz: 297cae39cab7c414c32f8d75ea2be17838b01518ab0d2c1fcd8ee800a233694f
4
+ data.tar.gz: f22c1fbe3123463efadda56b68e25175a48a89e76e7841e52d39de80c0f47398
5
5
  SHA512:
6
- metadata.gz: e649e3040acec1a88eb92075b555ed4ba7c2c7533544ba2c4da01d41627dcd570bede8315c1759018351803eca2b9f00e84b95533ebb5d6412f7ada6705dac3d
7
- data.tar.gz: 1077d3018207521015a4f4c5025c032b84405377d43a789a27b1153154eafac83e955abc75a5d4cb558073242caed193e3a018ae8251058ce88379a5c7e078ec
6
+ metadata.gz: b046d3ea9996dd97d59d300d7df36891ac0274144222f8d674fbad83f0718dda20bb575072839351236aab8ec7dbc5838035d12a9917319498bf022f8a83e83d
7
+ data.tar.gz: 86dcdf238843e616c688df07ba8d43436372d3ba18dff1266d9ae5f52cdb1631d5360d32b26a32ebf28a5f81c29e3a64ebde108d8b8416d4e53663b5d5147367
@@ -11,9 +11,9 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby-version: ["2.6", "2.7", "3.0"]
14
+ ruby-version: ["2.7", "3.0", "3.1"]
15
15
  steps:
16
- - uses: actions/checkout@v2
16
+ - uses: actions/checkout@v3
17
17
  - uses: ruby/setup-ruby@v1
18
18
  with:
19
19
  ruby-version: ${{ matrix.ruby-version }}
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ inherit_mode:
6
6
  - Exclude
7
7
 
8
8
  AllCops:
9
- TargetRubyVersion: "2.6"
9
+ TargetRubyVersion: "2.7"
10
10
 
11
11
  Naming/FileName:
12
12
  Exclude:
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+ gem 'mustermann', '< 2' # wait for deprecation warning fix
data/Gemfile.lock CHANGED
@@ -1,127 +1,123 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datadog-notifications (0.6.7)
4
+ datadog-notifications (0.7.1)
5
5
  activesupport
6
- dogstatsd-ruby (>= 4.8, < 5.0)
6
+ dogstatsd-ruby (>= 5.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activejob (6.1.3)
12
- activesupport (= 6.1.3)
11
+ activejob (7.0.4.1)
12
+ activesupport (= 7.0.4.1)
13
13
  globalid (>= 0.3.6)
14
- activemodel (6.1.3)
15
- activesupport (= 6.1.3)
16
- activerecord (6.1.3)
17
- activemodel (= 6.1.3)
18
- activesupport (= 6.1.3)
19
- activesupport (6.1.3)
14
+ activemodel (7.0.4.1)
15
+ activesupport (= 7.0.4.1)
16
+ activerecord (7.0.4.1)
17
+ activemodel (= 7.0.4.1)
18
+ activesupport (= 7.0.4.1)
19
+ activesupport (7.0.4.1)
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.8)
28
- diff-lcs (1.4.4)
29
- dogstatsd-ruby (4.8.3)
30
- dry-configurable (0.12.1)
26
+ concurrent-ruby (1.1.10)
27
+ diff-lcs (1.5.0)
28
+ dogstatsd-ruby (5.5.0)
29
+ dry-core (1.0.0)
31
30
  concurrent-ruby (~> 1.0)
32
- dry-core (~> 0.5, >= 0.5.0)
33
- dry-container (0.7.2)
31
+ zeitwerk (~> 2.6)
32
+ dry-inflector (1.0.0)
33
+ dry-logic (1.5.0)
34
34
  concurrent-ruby (~> 1.0)
35
- dry-configurable (~> 0.1, >= 0.1.3)
36
- dry-core (0.5.0)
35
+ dry-core (~> 1.0, < 2)
36
+ zeitwerk (~> 2.6)
37
+ dry-types (1.7.0)
37
38
  concurrent-ruby (~> 1.0)
38
- dry-inflector (0.2.0)
39
- dry-logic (1.1.0)
40
- concurrent-ruby (~> 1.0)
41
- dry-core (~> 0.5, >= 0.5)
42
- dry-types (1.5.1)
43
- concurrent-ruby (~> 1.0)
44
- dry-container (~> 0.3)
45
- dry-core (~> 0.5, >= 0.5)
46
- dry-inflector (~> 0.1, >= 0.1.2)
47
- dry-logic (~> 1.0, >= 1.0.2)
48
- globalid (0.4.2)
49
- activesupport (>= 4.2.0)
50
- grape (1.5.2)
39
+ dry-core (~> 1.0, < 2)
40
+ dry-inflector (~> 1.0, < 2)
41
+ dry-logic (>= 1.4, < 2)
42
+ zeitwerk (~> 2.6)
43
+ globalid (1.0.1)
44
+ activesupport (>= 5.0)
45
+ grape (1.7.0)
51
46
  activesupport
52
47
  builder
53
48
  dry-types (>= 1.1)
54
49
  mustermann-grape (~> 1.0.0)
55
50
  rack (>= 1.3.0)
56
51
  rack-accept
57
- i18n (1.8.9)
52
+ i18n (1.12.0)
58
53
  concurrent-ruby (~> 1.0)
59
- minitest (5.14.4)
60
- mustermann (1.1.1)
54
+ json (2.6.3)
55
+ mini_portile2 (2.8.1)
56
+ minitest (5.17.0)
57
+ mustermann (1.1.2)
61
58
  ruby2_keywords (~> 0.0.1)
62
- mustermann-grape (1.0.1)
59
+ mustermann-grape (1.0.2)
63
60
  mustermann (>= 1.0.0)
64
- parallel (1.20.1)
65
- parser (3.0.0.0)
61
+ parallel (1.22.1)
62
+ parser (3.2.0.0)
66
63
  ast (~> 2.4.1)
67
- rack (2.2.3)
64
+ rack (3.0.4.1)
68
65
  rack-accept (0.4.5)
69
66
  rack (>= 0.4)
70
- rack-test (1.1.0)
71
- rack (>= 1.0, < 3)
72
- rainbow (3.0.0)
73
- rake (13.0.3)
74
- regexp_parser (2.1.1)
67
+ rack-test (2.0.2)
68
+ rack (>= 1.3)
69
+ rainbow (3.1.1)
70
+ rake (13.0.6)
71
+ regexp_parser (2.6.2)
75
72
  rexml (3.2.5)
76
- rspec (3.10.0)
77
- rspec-core (~> 3.10.0)
78
- rspec-expectations (~> 3.10.0)
79
- rspec-mocks (~> 3.10.0)
80
- rspec-core (3.10.1)
81
- rspec-support (~> 3.10.0)
82
- rspec-expectations (3.10.1)
73
+ rspec (3.12.0)
74
+ rspec-core (~> 3.12.0)
75
+ rspec-expectations (~> 3.12.0)
76
+ rspec-mocks (~> 3.12.0)
77
+ rspec-core (3.12.0)
78
+ rspec-support (~> 3.12.0)
79
+ rspec-expectations (3.12.2)
83
80
  diff-lcs (>= 1.2.0, < 2.0)
84
- rspec-support (~> 3.10.0)
85
- rspec-mocks (3.10.2)
81
+ rspec-support (~> 3.12.0)
82
+ rspec-mocks (3.12.3)
86
83
  diff-lcs (>= 1.2.0, < 2.0)
87
- rspec-support (~> 3.10.0)
88
- rspec-support (3.10.2)
89
- rubocop (1.11.0)
84
+ rspec-support (~> 3.12.0)
85
+ rspec-support (3.12.0)
86
+ rubocop (1.43.0)
87
+ json (~> 2.3)
90
88
  parallel (~> 1.10)
91
- parser (>= 3.0.0.0)
89
+ parser (>= 3.2.0.0)
92
90
  rainbow (>= 2.2.2, < 4.0)
93
91
  regexp_parser (>= 1.8, < 3.0)
94
- rexml
95
- rubocop-ast (>= 1.2.0, < 2.0)
92
+ rexml (>= 3.2.5, < 4.0)
93
+ rubocop-ast (>= 1.24.1, < 2.0)
96
94
  ruby-progressbar (~> 1.7)
97
- unicode-display_width (>= 1.4.0, < 3.0)
98
- rubocop-ast (1.4.1)
99
- parser (>= 2.7.1.5)
100
- rubocop-bsm (0.5.4)
95
+ unicode-display_width (>= 2.4.0, < 3.0)
96
+ rubocop-ast (1.24.1)
97
+ parser (>= 3.1.1.0)
98
+ rubocop-bsm (0.6.1)
101
99
  rubocop (~> 1.0)
102
100
  rubocop-performance
103
- rubocop-rails
104
101
  rubocop-rake
105
102
  rubocop-rspec
106
- rubocop-performance (1.10.1)
107
- rubocop (>= 0.90.0, < 2.0)
103
+ rubocop-capybara (2.17.0)
104
+ rubocop (~> 1.41)
105
+ rubocop-performance (1.15.2)
106
+ rubocop (>= 1.7.0, < 2.0)
108
107
  rubocop-ast (>= 0.4.0)
109
- rubocop-rails (2.9.1)
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)
108
+ rubocop-rake (0.6.0)
116
109
  rubocop (~> 1.0)
117
- rubocop-ast (>= 1.1.0)
110
+ rubocop-rspec (2.18.1)
111
+ rubocop (~> 1.33)
112
+ rubocop-capybara (~> 2.17)
118
113
  ruby-progressbar (1.11.0)
119
- ruby2_keywords (0.0.4)
120
- sqlite3 (1.4.2)
121
- tzinfo (2.0.4)
114
+ ruby2_keywords (0.0.5)
115
+ sqlite3 (1.6.0)
116
+ mini_portile2 (~> 2.8.0)
117
+ tzinfo (2.0.5)
122
118
  concurrent-ruby (~> 1.0)
123
- unicode-display_width (2.0.0)
124
- zeitwerk (2.4.2)
119
+ unicode-display_width (2.4.2)
120
+ zeitwerk (2.6.6)
125
121
 
126
122
  PLATFORMS
127
123
  ruby
@@ -132,6 +128,7 @@ DEPENDENCIES
132
128
  bundler
133
129
  datadog-notifications!
134
130
  grape (>= 1.0.2)
131
+ mustermann (< 2)
135
132
  rack-test
136
133
  rake
137
134
  rspec
@@ -139,4 +136,4 @@ DEPENDENCIES
139
136
  sqlite3
140
137
 
141
138
  BUNDLED WITH
142
- 2.2.16
139
+ 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.6'
16
+ s.required_ruby_version = '>= 2.7'
18
17
 
19
18
  s.add_runtime_dependency 'activesupport'
20
- s.add_runtime_dependency 'dogstatsd-ruby', '>= 4.8', '< 5.0'
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['INSTRUMENTATION_HOSTNAME'] || Socket.gethostname
8
- @statsd_host = ENV['STATSD_HOST']
9
- @statsd_port = ENV['STATSD_PORT']
10
- @socket_path = ENV['SOCKET_PATH']
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['RAILS_ENV'] || ENV['RACK_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'
@@ -35,7 +35,7 @@ module Datadog::Notifications::Plugins
35
35
  status = exception_handler.call(payload[:exception_object]) if payload[:exception_object]
36
36
 
37
37
  path = extract_path(endpoint)
38
- path.gsub!(%r{[^\w/\-]+}, '_')
38
+ path.gsub!(%r{[^\w/-]+}, '_')
39
39
 
40
40
  tags = self.tags + %W[method:#{method} status:#{status}]
41
41
  tags.push "path:#{path}" if path
@@ -1,5 +1,5 @@
1
1
  module Datadog
2
2
  class Notifications
3
- VERSION = '0.6.7'.freeze
3
+ VERSION = '0.7.1'.freeze
4
4
  end
5
5
  end
@@ -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(Mock::Reporter)
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(Mock::Reporter)
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
- NoopJob.perform_now
6
- expect(buffered).to eq [
7
- 'activejob.perform:1|c|#custom:tag,env:test,host:test.host,job:noop,queue:test_queue',
8
- 'activejob.perform.time:333|ms|#custom:tag,env:test,host:test.host,job:noop,queue:test_queue',
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(buffered).to eq [
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:333|ms|#custom:tag,env:test,host:test.host,query:post.load',
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(buffered).to eq [
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:333|ms|#custom:tag,env:test,host:test.host,query:post.load',
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(buffered).to eq([
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:333|ms|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:200,path:/echo/KEY1/KEY2',
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(buffered).to eq([
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:333|ms|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:200,path:/api/sub/versioned,version:v1',
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(buffered).to eq([
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:333|ms|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:403,path:/sub/secure/resource',
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(buffered).to eq([
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:333|ms|#custom:tag,env:test,host:test.host,more:tags,method:GET,status:401,path:/rescued',
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(buffered).to eq([
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:333|ms|#custom:tag,env:test,host:test.host,more:tags,method:POST,status:405,path:/rescued',
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(buffered).to eq([])
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(Mock::Reporter)
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
- Mock::Instrumentable.new(method: 'GET').perform
27
- expect(buffered).to eq([
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:333|ms|#custom:tag,env:test,host:test.host,status:200,method:GET',
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
- ### Active-job test preparation
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 buffered
66
- Datadog::Notifications.instance.send(:reporter).messages
30
+ def messages
31
+ @messages ||= []
67
32
  end
68
33
  end
69
34
 
70
35
  c.include helpers
71
36
  c.before do
72
- buffered.clear
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.6.7
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-02 00:00:00.000000000 Z
11
+ date: 2023-01-23 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.6'
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.2.15
221
+ rubygems_version: 3.4.1
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: []