datadog-notifications 0.6.1 → 0.6.6

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: 472a4035494d388a59a5e218f0623dece5a45aac484f03031ee4c1a226687f58
4
- data.tar.gz: c54d689966289b3d420d7e69ac8909a791884a91b4eee874f83c370c87f215ef
3
+ metadata.gz: 299177adeebc9ed3fd6984f9725fb88ae46ab24b1582548976e8d4aa1a48f55a
4
+ data.tar.gz: bdea7f81d306dbb4f45d77b1870475596a3b9e04ef4675ca7ef117c03066be9a
5
5
  SHA512:
6
- metadata.gz: 9f1de08182535489a68e6d1090b9bf884b3cedc997e039a143a15d0f1ae77a7e5eeacd529e2b6e6dfce40d24fb8d630687431ac9a960fd1305b7330933cbaea6
7
- data.tar.gz: 591c6be1b9b0c07ce843c11d7983cf3dfdec252532cd8f68104418020adf37ed8f0864f2b7987b6fa06c4e4d259455eefa02caa4063892aaebbf3371d66d4b24
6
+ metadata.gz: 4c7a6359a6b6abc80be605d04dd8934d7460de1a16ec1f2c7d6018c7f37c5b036658b8fa022f459117ea2367157cdc1e601c6482b72ff5ecf85e6965835e4d4e
7
+ data.tar.gz: f72472a2cfee96d1cb79f6ceddccdc8103ba8dffdd86465866dc17236ac95b59822558bad85cb40e848f4372a2ef588ba1bcd2fc7e3834a8e0415a2f23f0cbc7
@@ -0,0 +1,21 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ["2.6", "2.7", "3.0"]
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ bundler-cache: true
21
+ - run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,8 +1,12 @@
1
- inherit_from:
2
- - https://gitlab.com/bsm/misc/raw/master/rubocop/default.yml
1
+ inherit_gem:
2
+ rubocop-bsm:
3
+ - default.yml
4
+ inherit_mode:
5
+ merge:
6
+ - Exclude
3
7
 
4
8
  AllCops:
5
- TargetRubyVersion: "2.3"
9
+ TargetRubyVersion: "2.6"
6
10
 
7
11
  Naming/FileName:
8
12
  Exclude:
data/Gemfile.lock CHANGED
@@ -1,97 +1,122 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datadog-notifications (0.6.1)
4
+ datadog-notifications (0.6.6)
5
5
  activesupport
6
- dogstatsd-ruby (>= 4.2, < 5.0)
6
+ dogstatsd-ruby (>= 4.8, < 5.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (5.2.3)
12
- activesupport (= 5.2.3)
13
- activerecord (5.2.3)
14
- activemodel (= 5.2.3)
15
- activesupport (= 5.2.3)
16
- arel (>= 9.0)
17
- activesupport (5.2.3)
11
+ activemodel (6.1.3)
12
+ activesupport (= 6.1.3)
13
+ activerecord (6.1.3)
14
+ activemodel (= 6.1.3)
15
+ activesupport (= 6.1.3)
16
+ activesupport (6.1.3)
18
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
- i18n (>= 0.7, < 2)
20
- minitest (~> 5.1)
21
- tzinfo (~> 1.1)
22
- arel (9.0.0)
23
- ast (2.4.0)
24
- axiom-types (0.1.1)
25
- descendants_tracker (~> 0.0.4)
26
- ice_nine (~> 0.11.0)
27
- thread_safe (~> 0.3, >= 0.3.1)
28
- builder (3.2.3)
29
- coercible (1.0.0)
30
- descendants_tracker (~> 0.0.1)
31
- concurrent-ruby (1.1.5)
32
- descendants_tracker (0.0.4)
33
- thread_safe (~> 0.3, >= 0.3.1)
34
- diff-lcs (1.3)
35
- dogstatsd-ruby (4.2.0)
36
- equalizer (0.0.11)
37
- grape (1.2.3)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
21
+ zeitwerk (~> 2.3)
22
+ ast (2.4.2)
23
+ builder (3.2.4)
24
+ concurrent-ruby (1.1.8)
25
+ diff-lcs (1.4.4)
26
+ dogstatsd-ruby (4.8.3)
27
+ dry-configurable (0.12.1)
28
+ concurrent-ruby (~> 1.0)
29
+ dry-core (~> 0.5, >= 0.5.0)
30
+ dry-container (0.7.2)
31
+ concurrent-ruby (~> 1.0)
32
+ dry-configurable (~> 0.1, >= 0.1.3)
33
+ dry-core (0.5.0)
34
+ concurrent-ruby (~> 1.0)
35
+ dry-inflector (0.2.0)
36
+ dry-logic (1.1.0)
37
+ concurrent-ruby (~> 1.0)
38
+ dry-core (~> 0.5, >= 0.5)
39
+ dry-types (1.5.1)
40
+ concurrent-ruby (~> 1.0)
41
+ dry-container (~> 0.3)
42
+ dry-core (~> 0.5, >= 0.5)
43
+ dry-inflector (~> 0.1, >= 0.1.2)
44
+ dry-logic (~> 1.0, >= 1.0.2)
45
+ grape (1.5.2)
38
46
  activesupport
39
47
  builder
48
+ dry-types (>= 1.1)
40
49
  mustermann-grape (~> 1.0.0)
41
50
  rack (>= 1.3.0)
42
51
  rack-accept
43
- virtus (>= 1.0.0)
44
- i18n (1.6.0)
52
+ i18n (1.8.9)
45
53
  concurrent-ruby (~> 1.0)
46
- ice_nine (0.11.2)
47
- jaro_winkler (1.5.2)
48
- minitest (5.11.3)
49
- mustermann (1.0.3)
50
- mustermann-grape (1.0.0)
51
- mustermann (~> 1.0.0)
52
- parallel (1.17.0)
53
- parser (2.6.2.1)
54
- ast (~> 2.4.0)
55
- psych (3.1.0)
56
- rack (2.0.7)
54
+ minitest (5.14.4)
55
+ mustermann (1.1.1)
56
+ ruby2_keywords (~> 0.0.1)
57
+ mustermann-grape (1.0.1)
58
+ mustermann (>= 1.0.0)
59
+ parallel (1.20.1)
60
+ parser (3.0.0.0)
61
+ ast (~> 2.4.1)
62
+ rack (2.2.3)
57
63
  rack-accept (0.4.5)
58
64
  rack (>= 0.4)
59
65
  rack-test (1.1.0)
60
66
  rack (>= 1.0, < 3)
61
67
  rainbow (3.0.0)
62
- rake (12.3.2)
63
- rspec (3.8.0)
64
- rspec-core (~> 3.8.0)
65
- rspec-expectations (~> 3.8.0)
66
- rspec-mocks (~> 3.8.0)
67
- rspec-core (3.8.0)
68
- rspec-support (~> 3.8.0)
69
- rspec-expectations (3.8.2)
68
+ rake (13.0.3)
69
+ regexp_parser (2.1.1)
70
+ rexml (3.2.4)
71
+ rspec (3.10.0)
72
+ rspec-core (~> 3.10.0)
73
+ rspec-expectations (~> 3.10.0)
74
+ rspec-mocks (~> 3.10.0)
75
+ rspec-core (3.10.1)
76
+ rspec-support (~> 3.10.0)
77
+ rspec-expectations (3.10.1)
70
78
  diff-lcs (>= 1.2.0, < 2.0)
71
- rspec-support (~> 3.8.0)
72
- rspec-mocks (3.8.0)
79
+ rspec-support (~> 3.10.0)
80
+ rspec-mocks (3.10.2)
73
81
  diff-lcs (>= 1.2.0, < 2.0)
74
- rspec-support (~> 3.8.0)
75
- rspec-support (3.8.0)
76
- rubocop (0.67.2)
77
- jaro_winkler (~> 1.5.1)
82
+ rspec-support (~> 3.10.0)
83
+ rspec-support (3.10.2)
84
+ rubocop (1.11.0)
78
85
  parallel (~> 1.10)
79
- parser (>= 2.5, != 2.5.1.1)
80
- psych (>= 3.1.0)
86
+ parser (>= 3.0.0.0)
81
87
  rainbow (>= 2.2.2, < 4.0)
88
+ regexp_parser (>= 1.8, < 3.0)
89
+ rexml
90
+ rubocop-ast (>= 1.2.0, < 2.0)
82
91
  ruby-progressbar (~> 1.7)
83
- unicode-display_width (>= 1.4.0, < 1.6)
84
- ruby-progressbar (1.10.0)
85
- sqlite3 (1.4.0)
86
- thread_safe (0.3.6)
87
- tzinfo (1.2.5)
88
- thread_safe (~> 0.1)
89
- unicode-display_width (1.5.0)
90
- virtus (1.0.5)
91
- axiom-types (~> 0.1)
92
- coercible (~> 1.0)
93
- descendants_tracker (~> 0.0, >= 0.0.3)
94
- equalizer (~> 0.0, >= 0.0.9)
92
+ unicode-display_width (>= 1.4.0, < 3.0)
93
+ rubocop-ast (1.4.1)
94
+ parser (>= 2.7.1.5)
95
+ rubocop-bsm (0.5.4)
96
+ rubocop (~> 1.0)
97
+ rubocop-performance
98
+ rubocop-rails
99
+ rubocop-rake
100
+ rubocop-rspec
101
+ rubocop-performance (1.10.1)
102
+ rubocop (>= 0.90.0, < 2.0)
103
+ rubocop-ast (>= 0.4.0)
104
+ rubocop-rails (2.9.1)
105
+ activesupport (>= 4.2.0)
106
+ rack (>= 1.1)
107
+ rubocop (>= 0.90.0, < 2.0)
108
+ rubocop-rake (0.5.1)
109
+ rubocop
110
+ rubocop-rspec (2.2.0)
111
+ rubocop (~> 1.0)
112
+ rubocop-ast (>= 1.1.0)
113
+ ruby-progressbar (1.11.0)
114
+ ruby2_keywords (0.0.4)
115
+ sqlite3 (1.4.2)
116
+ tzinfo (2.0.4)
117
+ concurrent-ruby (~> 1.0)
118
+ unicode-display_width (2.0.0)
119
+ zeitwerk (2.4.2)
95
120
 
96
121
  PLATFORMS
97
122
  ruby
@@ -104,8 +129,8 @@ DEPENDENCIES
104
129
  rack-test
105
130
  rake
106
131
  rspec
107
- rubocop
132
+ rubocop-bsm
108
133
  sqlite3
109
134
 
110
135
  BUNDLED WITH
111
- 1.17.3
136
+ 2.1.4
@@ -14,10 +14,10 @@ Gem::Specification.new do |s|
14
14
  s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
15
  s.test_files = s.files.grep(%r{^(spec)/})
16
16
  s.require_paths = ['lib']
17
- s.required_ruby_version = '>= 2.3'
17
+ s.required_ruby_version = '>= 2.6'
18
18
 
19
19
  s.add_runtime_dependency 'activesupport'
20
- s.add_runtime_dependency 'dogstatsd-ruby', '>= 4.2', '< 5.0'
20
+ s.add_runtime_dependency 'dogstatsd-ruby', '>= 4.8', '< 5.0'
21
21
 
22
22
  s.add_development_dependency 'activerecord'
23
23
  s.add_development_dependency 'bundler'
@@ -25,6 +25,6 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency 'rack-test'
26
26
  s.add_development_dependency 'rake'
27
27
  s.add_development_dependency 'rspec'
28
- s.add_development_dependency 'rubocop'
28
+ s.add_development_dependency 'rubocop-bsm'
29
29
  s.add_development_dependency 'sqlite3'
30
30
  end
@@ -14,22 +14,21 @@ module Datadog
14
14
  end
15
15
 
16
16
  # Use a plugin
17
- def use(klass, opts={})
18
- @plugins.push klass.new(opts)
17
+ def use(klass, **opts)
18
+ @plugins.push klass.new(**opts)
19
19
  end
20
20
 
21
21
  protected
22
22
 
23
23
  def connect!
24
24
  env = ENV['RAILS_ENV'] || ENV['RACK_ENV']
25
- tags.push("env:#{env}") if env && tags.none? {|t| t =~ /^env\:/ }
25
+ tags.push("env:#{env}") if env && tags.none? {|t| t =~ /^env:/ }
26
26
 
27
27
  enable_hostname = hostname && hostname != 'false'
28
- tags.push("host:#{hostname}") if enable_hostname && tags.none? {|t| t =~ /^host\:/ }
28
+ tags.push("host:#{hostname}") if enable_hostname && tags.none? {|t| t =~ /^host:/ }
29
29
 
30
30
  reporter.new statsd_host, statsd_port, namespace: namespace, tags: tags, socket_path: socket_path
31
31
  end
32
-
33
32
  end
34
33
  end
35
34
  end
@@ -1,16 +1,15 @@
1
1
  module Datadog::Notifications::Plugins
2
2
  class ActionController < Base
3
-
4
3
  attr_reader :metric_name
5
4
 
6
5
  # Options:
7
6
  #
8
7
  # *<tt>:metric_name</tt> - the metric name, defaults to "rails.request"
9
8
  # *<tt>:tags</tt> - additional tags
10
- def initialize(opts={})
9
+ def initialize(metric_name: 'rails.request', **opts)
11
10
  super
12
- @metric_name = opts[:metric_name] || 'rails.request'
13
11
 
12
+ @metric_name = metric_name
14
13
  Datadog::Notifications.subscribe 'process_action.action_controller' do |reporter, event|
15
14
  record reporter, event
16
15
  end
@@ -34,6 +33,5 @@ module Datadog::Notifications::Plugins
34
33
  reporter.timing "#{metric_name}.time.view", payload[:view_runtime], tags: tags
35
34
  end
36
35
  end
37
-
38
36
  end
39
37
  end
@@ -1,16 +1,15 @@
1
1
  module Datadog::Notifications::Plugins
2
2
  class ActiveJob < Base
3
-
4
3
  attr_reader :metric_name
5
4
 
6
5
  # Options:
7
6
  #
8
7
  # *<tt>:metric_name</tt> - the metric name, defaults to "activejob.perform"
9
8
  # *<tt>:tags</tt> - additional tags
10
- def initialize(opts={})
9
+ def initialize(metric_name: 'activejob.perform', **opts)
11
10
  super
12
- @metric_name = opts[:metric_name] || 'activejob.perform'
13
11
 
12
+ @metric_name = metric_name
14
13
  Datadog::Notifications.subscribe 'perform.active_job' do |reporter, event|
15
14
  record reporter, event
16
15
  end
@@ -28,6 +27,5 @@ module Datadog::Notifications::Plugins
28
27
  reporter.timing "#{metric_name}.time", event.duration, tags: tags
29
28
  end
30
29
  end
31
-
32
30
  end
33
31
  end
@@ -1,6 +1,5 @@
1
1
  module Datadog::Notifications::Plugins
2
2
  class ActiveRecord < Base
3
-
4
3
  attr_reader :metric_name
5
4
 
6
5
  # Options:
@@ -9,9 +8,10 @@ module Datadog::Notifications::Plugins
9
8
  # *<tt>:include_schema</tt> - record schema queries, off by default
10
9
  # *<tt>:include_generic</tt> - record general (nameless) queries, off by default
11
10
  # *<tt>:tags</tt> - additional tags
12
- def initialize(opts={})
11
+ def initialize(metric_name: 'activerecord.sql', **opts)
13
12
  super
14
- @metric_name = opts[:metric_name] || 'activerecord.sql'
13
+
14
+ @metric_name = metric_name
15
15
  @include_schema = opts[:include_schema] == true
16
16
  @include_generic = opts[:include_generic] == true
17
17
  @include_raw = opts[:include_raw] == true
@@ -38,6 +38,5 @@ module Datadog::Notifications::Plugins
38
38
  reporter.timing "#{metric_name}.time", event.duration, tags: tags
39
39
  end
40
40
  end
41
-
42
41
  end
43
42
  end
@@ -5,9 +5,8 @@ module Datadog::Notifications::Plugins
5
5
  # Options:
6
6
  #
7
7
  # *<tt>:tags</tt> - additional tags
8
- def initialize(opts={})
9
- @tags = opts[:tags] || []
8
+ def initialize(tags: [], **_opts)
9
+ @tags = tags
10
10
  end
11
-
12
11
  end
13
12
  end
@@ -1,5 +1,6 @@
1
1
  module Datadog::Notifications::Plugins
2
2
  class Grape < Base
3
+ DEFAULT_EXCEPTION_HANDLER = ->(e) { Grape.exception_status(e) }
3
4
 
4
5
  def self.exception_status(err)
5
6
  err.respond_to?(:status) ? err.status : 500
@@ -12,10 +13,11 @@ module Datadog::Notifications::Plugins
12
13
  # *<tt>:metric_name</tt> - the metric name, defaults to "grape.request"
13
14
  # *<tt>:exception_handler</tt> - a custom exception handler proc which accepts an exception object and returns a status
14
15
  # *<tt>:tags</tt> - additional tags
15
- def initialize(opts={})
16
+ def initialize(metric_name: 'grape.request', exception_handler: DEFAULT_EXCEPTION_HANDLER, **opts)
16
17
  super
17
- @metric_name = opts[:metric_name] || 'grape.request'
18
- @exception_handler = opts[:exception_handler] || ->(e) { self.class.exception_status(e) }
18
+
19
+ @metric_name = metric_name
20
+ @exception_handler = exception_handler
19
21
 
20
22
  Datadog::Notifications.subscribe 'endpoint_run.grape' do |reporter, event|
21
23
  record reporter, event
@@ -33,7 +35,7 @@ module Datadog::Notifications::Plugins
33
35
  status = exception_handler.call(payload[:exception_object]) if payload[:exception_object]
34
36
 
35
37
  path = extract_path(endpoint)
36
- path.gsub!(%r{[^\w\/\-]+}, '_')
38
+ path.gsub!(%r{[^\w/\-]+}, '_')
37
39
 
38
40
  tags = self.tags + %W[method:#{method} status:#{status}]
39
41
  tags.push "path:#{path}" if path
@@ -47,18 +49,17 @@ module Datadog::Notifications::Plugins
47
49
 
48
50
  def extract_path(endpoint)
49
51
  route = begin
50
- endpoint.route
51
- rescue NoMethodError
52
- nil
53
- end
52
+ endpoint.route
53
+ rescue NoMethodError
54
+ nil
55
+ end
54
56
  return endpoint.request.path unless route
55
57
 
56
58
  path = endpoint.route.path.dup
57
- path.sub!(/\(\.\:format\)$/, '')
59
+ path.sub!(/\(\.:format\)$/, '')
58
60
  path.sub!(':version/', '') if endpoint.version
59
- path.gsub!(/:(\w+)/) {|m| m[1..-1].upcase }
61
+ path.gsub!(/:(\w+)/) {|m| m[1..].upcase }
60
62
  path
61
63
  end
62
-
63
64
  end
64
65
  end
@@ -1,6 +1,5 @@
1
1
  module Datadog::Notifications::Plugins
2
2
  class GRPC < Base
3
-
4
3
  # Options:
5
4
  #
6
5
  # *<tt>:metric_name</tt> - the metric name, defaults to 'grpc.request'
@@ -10,10 +9,10 @@ module Datadog::Notifications::Plugins
10
9
  # Notification payload should have :service (service name, string) and :action (service action/method name, string) keys.
11
10
  #
12
11
  # Compatible instrumentation is implemented in grpcx gem: https://github.com/bsm/grpcx (>= 0.2.0)
13
- def initialize(opts={})
12
+ def initialize(metric_name: 'grpc.request', **opts)
14
13
  super
15
- @metric_name = opts[:metric_name] || 'grpc.request'
16
14
 
15
+ @metric_name = metric_name
17
16
  Datadog::Notifications.subscribe 'process_action.grpc' do |reporter, event|
18
17
  record reporter, event
19
18
  end
@@ -34,6 +33,5 @@ module Datadog::Notifications::Plugins
34
33
  reporter.timing "#{@metric_name}.time", event.duration, tags: tags
35
34
  end
36
35
  end
37
-
38
36
  end
39
37
  end
@@ -1,5 +1,5 @@
1
1
  module Datadog
2
2
  class Notifications
3
- VERSION = '0.6.1'.freeze
3
+ VERSION = '0.6.6'.freeze
4
4
  end
5
5
  end
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Datadog::Notifications::Config do
4
-
5
- it 'should be connect!' do
4
+ it 'is connect!' do
6
5
  subject.reporter = Mock::Reporter
7
6
  subject.hostname = 'test.host'
8
7
  subject.tags = ['custom:tag']
@@ -13,7 +12,7 @@ describe Datadog::Notifications::Config do
13
12
  end
14
13
 
15
14
  RSpec.shared_examples 'host tag is not picked up' do |hostname|
16
- it 'should not pick up the host tag' do
15
+ it 'does not pick up the host tag' do
17
16
  subject.reporter = Mock::Reporter
18
17
  subject.hostname = hostname
19
18
  subject.tags = ['custom:tag']
@@ -27,10 +26,9 @@ describe Datadog::Notifications::Config do
27
26
  include_examples 'host tag is not picked up', false
28
27
  include_examples 'host tag is not picked up', 'false'
29
28
 
30
- it 'should instantiate plugins on use' do
29
+ it 'instantiates plugins on use' do
31
30
  subject.use Datadog::Notifications::Plugins::ActionController
32
31
  expect(subject.plugins.size).to eq(1)
33
32
  expect(subject.plugins.first).to be_instance_of(Datadog::Notifications::Plugins::ActionController)
34
33
  end
35
-
36
34
  end
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Datadog::Notifications::Plugins::ActiveRecord do
4
-
5
- it 'should send an increment and timing event for each query' do
4
+ it 'sends an increment and timing event for each query' do
6
5
  Post.all.to_a
7
6
  expect(buffered).to eq [
8
7
  'activerecord.sql:1|c|#custom:tag,env:test,host:test.host,query:post.load',
@@ -10,12 +9,11 @@ describe Datadog::Notifications::Plugins::ActiveRecord do
10
9
  ]
11
10
  end
12
11
 
13
- it 'should support custom queries' do
12
+ it 'supports custom queries' do
14
13
  Post.find_by_sql('SELECT * FROM posts LIMIT 1').to_a
15
14
  expect(buffered).to eq [
16
15
  'activerecord.sql:1|c|#custom:tag,env:test,host:test.host,query:post.load',
17
16
  'activerecord.sql.time:333|ms|#custom:tag,env:test,host:test.host,query:post.load',
18
17
  ]
19
18
  end
20
-
21
19
  end
@@ -14,7 +14,6 @@ describe Datadog::Notifications::Plugins::Grape do
14
14
  end
15
15
 
16
16
  Class.new(Grape::API) do
17
-
18
17
  rescue_from unauthorized do |_e|
19
18
  error!({ message: 'unauthorized', error: '401 Unauthorized' }, 401)
20
19
  end
@@ -37,7 +36,7 @@ describe Datadog::Notifications::Plugins::Grape do
37
36
  end
38
37
  end
39
38
 
40
- it 'should send an increment and timing event for each request' do
39
+ it 'sends an increment and timing event for each request' do
41
40
  get '/echo/1/1234'
42
41
  expect(last_response.status).to eq(200)
43
42
  expect(last_response.body).to eq('1 1234')
@@ -48,7 +47,7 @@ describe Datadog::Notifications::Plugins::Grape do
48
47
  ])
49
48
  end
50
49
 
51
- it 'should support namespaces and versioning' do
50
+ it 'supports namespaces and versioning' do
52
51
  get '/api/v1/sub/versioned.txt'
53
52
  expect(last_response.status).to eq(200)
54
53
  expect(last_response.body).to eq('OK')
@@ -59,7 +58,7 @@ describe Datadog::Notifications::Plugins::Grape do
59
58
  ])
60
59
  end
61
60
 
62
- it 'should support deep nesting' do
61
+ it 'supports deep nesting' do
63
62
  get '/sub/secure/resource'
64
63
  expect(last_response.status).to eq(403)
65
64
  expect(last_response.body).to eq('forbidden')
@@ -70,7 +69,7 @@ describe Datadog::Notifications::Plugins::Grape do
70
69
  ])
71
70
  end
72
71
 
73
- it 'should handle rescued errors' do
72
+ it 'handles rescued errors' do
74
73
  get '/rescued'
75
74
  expect(last_response.status).to eq(401)
76
75
 
@@ -80,7 +79,7 @@ describe Datadog::Notifications::Plugins::Grape do
80
79
  ])
81
80
  end
82
81
 
83
- it 'should handle invalid method' do
82
+ it 'handles invalid method' do
84
83
  post '/rescued'
85
84
 
86
85
  expect(last_response.status).to eq(405)
@@ -90,11 +89,10 @@ describe Datadog::Notifications::Plugins::Grape do
90
89
  ])
91
90
  end
92
91
 
93
- it 'should not report paths on 404s' do
92
+ it 'does not report paths on 404s' do
94
93
  get '/sub/missing'
95
94
  expect(last_response.status).to eq(404)
96
95
 
97
96
  expect(buffered).to eq([])
98
97
  end
99
-
100
98
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Datadog::Notifications do
4
-
5
4
  subject { described_class.instance }
5
+
6
6
  after { ActiveSupport::Notifications.unsubscribe(subscription) }
7
7
 
8
8
  let!(:subscription) do
@@ -18,16 +18,15 @@ describe Datadog::Notifications do
18
18
  end
19
19
  end
20
20
 
21
- it 'should have a reporter' do
21
+ it 'has a reporter' do
22
22
  expect(subject.send(:reporter)).to be_instance_of(Mock::Reporter)
23
23
  end
24
24
 
25
- it 'should subscribe and report' do
25
+ it 'subscribes and report' do
26
26
  Mock::Instrumentable.new(method: 'GET').perform
27
27
  expect(buffered).to eq([
28
28
  'web.render:1|c|#custom:tag,env:test,host:test.host,status:200,method:GET',
29
29
  'web.render.time:333|ms|#custom:tag,env:test,host:test.host,status:200,method:GET',
30
30
  ])
31
31
  end
32
-
33
32
  end
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,7 @@ require 'sqlite3'
10
10
 
11
11
  ### Active-record test preparation
12
12
 
13
- ActiveRecord::Base.configurations['test'] = { 'adapter' => 'sqlite3', 'database' => ':memory:' }
13
+ ActiveRecord::Base.configurations = { 'test' => { 'adapter' => 'sqlite3', 'database' => ':memory:' } }
14
14
  ActiveRecord::Base.establish_connection(:test)
15
15
  ActiveRecord::Base.connection.create_table :posts do |t|
16
16
  t.string :title
@@ -22,8 +22,8 @@ end
22
22
 
23
23
  module Mock
24
24
  class Reporter < Datadog::Notifications::Reporter
25
- def timing(stat, _millis, opts={})
26
- super(stat, 333, opts)
25
+ def timing(stat, _millis, **opts)
26
+ super(stat, 333, **opts)
27
27
  end
28
28
 
29
29
  def send_stat(message)
@@ -36,7 +36,7 @@ module Mock
36
36
  end
37
37
 
38
38
  class Instrumentable
39
- def initialize(opts={})
39
+ def initialize(**opts)
40
40
  @opts = opts
41
41
  end
42
42
 
@@ -71,13 +71,13 @@ Datadog::Notifications.configure do |c|
71
71
 
72
72
  c.use Datadog::Notifications::Plugins::ActiveRecord
73
73
  c.use Datadog::Notifications::Plugins::Grape,
74
- tags: ['more:tags'],
75
- metric_name: 'api.request',
76
- exception_handler: lambda {|e|
77
- if e.message.include?('unauthorized')
78
- 401
79
- else
80
- Datadog::Notifications::Plugins::Grape.exception_status(e)
81
- end
82
- }
74
+ tags: ['more:tags'],
75
+ metric_name: 'api.request',
76
+ exception_handler: lambda {|e|
77
+ if e.message.include?('unauthorized')
78
+ 401
79
+ else
80
+ Datadog::Notifications::Plugins::Grape.exception_status(e)
81
+ end
82
+ }
83
83
  end
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.1
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-17 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.2'
33
+ version: '4.8'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '5.0'
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: '4.2'
43
+ version: '4.8'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '5.0'
@@ -129,7 +129,7 @@ dependencies:
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  - !ruby/object:Gem::Dependency
132
- name: rubocop
132
+ name: rubocop-bsm
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - ">="
@@ -164,10 +164,9 @@ extensions: []
164
164
  extra_rdoc_files: []
165
165
  files:
166
166
  - ".editorconfig"
167
+ - ".github/workflows/ruby.yml"
167
168
  - ".gitignore"
168
- - ".rake_tasks~"
169
169
  - ".rubocop.yml"
170
- - ".travis.yml"
171
170
  - Gemfile
172
171
  - Gemfile.lock
173
172
  - MIT-LICENCE
@@ -202,14 +201,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
201
  requirements:
203
202
  - - ">="
204
203
  - !ruby/object:Gem::Version
205
- version: '2.3'
204
+ version: '2.6'
206
205
  required_rubygems_version: !ruby/object:Gem::Requirement
207
206
  requirements:
208
207
  - - ">="
209
208
  - !ruby/object:Gem::Version
210
209
  version: '0'
211
210
  requirements: []
212
- rubygems_version: 3.0.3
211
+ rubygems_version: 3.1.4
213
212
  signing_key:
214
213
  specification_version: 4
215
214
  summary: Generic ActiveSupport::Notifications Datadog handler
data/.rake_tasks~ DELETED
@@ -1,9 +0,0 @@
1
- build
2
- clean
3
- clobber
4
- install
5
- install:local
6
- release[remote]
7
- rubocop
8
- rubocop:auto_correct
9
- spec
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- cache: bundler
2
- language: ruby
3
- rvm:
4
- - 2.6
5
- - 2.5
6
- - 2.4
7
- - 2.3