sidekiq-datadog 0.4.0 → 0.4.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: 5f4d345b0e6b984519eca3a6e088f387649fc5bbc46d414fc3ed0165f8ca9db7
4
- data.tar.gz: 0d9b85a785bea3e9ca60d2a62604c90eef649754a0f6377e32aa115eb0a0eb95
3
+ metadata.gz: 587cd9c94eb2d0018ddc31e367990f2f0121c40061e8437e6ed0d1491f16a499
4
+ data.tar.gz: b9e3cf7e254ecb3f26c1df1969f5d40cd20113fed85d69de13792001ec02be87
5
5
  SHA512:
6
- metadata.gz: 5da1867bec33ef19c61ac30efe3f37aef687f77c509a1859d69028fbeade3f49ae4543604bbf21a6c16a2ed980f0f025dbc31f7f09f37119b8a39f554e1b4cfa
7
- data.tar.gz: 62cff0b0830b3a3caba520257827524fc49f59f307abfb5476d67b96911bb96db3db21d6fbdeccef2586b7f10c7e2bd1925f76601ae85cf872ac1af197cb18c8
6
+ metadata.gz: 3abe152091c7c6cce17d943b830f37cf1954a0151c9662fd562d5d4f64fc5d7df87118bcdd8d4e211e1398a2fa9b9af24f0f9f7644c3f20135c93a7825778c54
7
+ data.tar.gz: f0eb0e04d485c4d915d7c9a1198946725ed9e99be82b2130f4fb39fa19fb04a205a64576f5353f0a907f5ddc608f1baeb643dd21046554ce192e5ebe76b76936
data/Gemfile.lock CHANGED
@@ -1,38 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sidekiq-datadog (0.4.0)
4
+ sidekiq-datadog (0.4.1)
5
5
  dogstatsd-ruby (>= 3.3.0)
6
6
  sidekiq
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- concurrent-ruby (1.0.5)
12
11
  connection_pool (2.2.2)
13
12
  diff-lcs (1.3)
14
- dogstatsd-ruby (3.3.0)
13
+ dogstatsd-ruby (4.0.0)
15
14
  rack (2.0.5)
16
15
  rack-protection (2.0.3)
17
16
  rack
18
17
  rake (12.3.1)
19
- redis (4.0.1)
20
- rspec (3.7.0)
21
- rspec-core (~> 3.7.0)
22
- rspec-expectations (~> 3.7.0)
23
- rspec-mocks (~> 3.7.0)
24
- rspec-core (3.7.1)
25
- rspec-support (~> 3.7.0)
26
- rspec-expectations (3.7.0)
18
+ redis (4.0.2)
19
+ rspec (3.8.0)
20
+ rspec-core (~> 3.8.0)
21
+ rspec-expectations (~> 3.8.0)
22
+ rspec-mocks (~> 3.8.0)
23
+ rspec-core (3.8.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-expectations (3.8.1)
27
26
  diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.7.0)
29
- rspec-mocks (3.7.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-mocks (3.8.0)
30
29
  diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.7.0)
32
- rspec-support (3.7.1)
33
- sidekiq (5.1.3)
34
- concurrent-ruby (~> 1.0)
35
- connection_pool (~> 2.2, >= 2.2.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-support (3.8.0)
32
+ sidekiq (5.2.1)
33
+ connection_pool (~> 2.2, >= 2.2.2)
36
34
  rack-protection (>= 1.5.0)
37
35
  redis (>= 3.3.5, < 5)
38
36
 
@@ -46,4 +44,4 @@ DEPENDENCIES
46
44
  sidekiq-datadog!
47
45
 
48
46
  BUNDLED WITH
49
- 1.16.2
47
+ 1.16.4
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Datadog
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
@@ -61,7 +61,7 @@ module Sidekiq
61
61
  queued_ms = ((start - Time.at(job["enqueued_at"])) * 1000).round
62
62
  end
63
63
  name = underscore(job['wrapped'] || worker.class.to_s)
64
- tags = @tags.map do |tag|
64
+ tags = @tags.flat_map do |tag|
65
65
  case tag when String then tag when Proc then tag.call(worker, job, queue, error) end
66
66
  end
67
67
 
@@ -2,11 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe Sidekiq::Middleware::Server::Datadog do
4
4
 
5
- let(:statsd) { Mock::Statsd.new(nil, nil, {}, 10000) }
5
+ let(:statsd) { Mock::Statsd.new('localhost', 55555) }
6
6
  let(:worker) { Mock::Worker.new }
7
+ let(:tags) {
8
+ ["custom:tag", lambda{|w, *| "worker:#{w.class.name[1..2]}" }]
9
+ }
7
10
 
8
11
  before { statsd.written.clear }
9
- subject { described_class.new hostname: "test.host", statsd: statsd, tags: ["custom:tag", lambda{|w, *| "worker:#{w.class.name[1..2]}" }] }
12
+ subject { described_class.new hostname: "test.host", statsd: statsd, tags: tags }
10
13
 
11
14
  it 'should send an increment and timing event for each job run' do
12
15
  subject.call(worker, { 'enqueued_at' => 1461881794.9312189 }, 'default') { "ok" }
@@ -37,4 +40,20 @@ describe Sidekiq::Middleware::Server::Datadog do
37
40
  ])
38
41
  end
39
42
 
43
+ context 'with a dynamic tag list' do
44
+ let(:tags) {
45
+ ["custom:tag", lambda {|w, j, *| j['args'].map { |n| "arg:#{n}"} }]
46
+ }
47
+
48
+ it 'should generate the correct tags' do
49
+ subject.call(worker, { 'enqueued_at' => 1461881794.9312189, 'args' => [1, 2] }, 'default') { "ok" }
50
+
51
+ expect(statsd.written).to eq([
52
+ "sidekiq.job:1|c|#custom:tag,arg:1,arg:2,host:test.host,env:test,name:mock/worker,queue:default,status:ok",
53
+ "sidekiq.job.time:333|ms|#custom:tag,arg:1,arg:2,host:test.host,env:test,name:mock/worker,queue:default,status:ok",
54
+ "sidekiq.job.queued_time:333|ms|#custom:tag,arg:1,arg:2,host:test.host,env:test,name:mock/worker,queue:default,status:ok"
55
+ ])
56
+ end
57
+ end
58
+
40
59
  end
data/spec/spec_helper.rb CHANGED
@@ -11,7 +11,7 @@ module Mock
11
11
 
12
12
  class Statsd < ::Datadog::Statsd
13
13
  def timing(stat, ms, opts={}); super(stat, 333, opts); end
14
- def send_to_socket(message); written.push(message); end
14
+ def send_stat(message); written.push(message); end
15
15
  def written; @written ||= []; end
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-datadog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.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: 2018-07-24 00:00:00.000000000 Z
11
+ date: 2018-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.7.7
123
+ rubygems_version: 2.7.6
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Datadog metrics for sidekiq