sidekiq-instrumental 0.3.3.beta1 → 0.3.4

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: 2014d2899db54a56adf4eba1b904e2535f1913ab8cf85cca87b2c0e2c3d70d3d
4
- data.tar.gz: 8075a76ffa10c9ab9a7c9665d32997fa7cbf0d5d462ff13a1899f15fe3181239
3
+ metadata.gz: d14f250c271b145a6c61534eff188d74ed8f8382d57ab5528222a3a2bb924756
4
+ data.tar.gz: 8dddb6c4aa02f3d71f6e43ed09e78d9f3da62f6ab3c453eed266ca15fa7c4ef7
5
5
  SHA512:
6
- metadata.gz: ad52c52631e1721a628a0381df96efc1f6ddb6336d898abdd0695366fa70581fc5924d045434b8ac67903d6c460b64902d18a06330a53655ad5166f615b08fe6
7
- data.tar.gz: 9c38a6c7a8744885651773321d523f012f1584685c9b9c021fb4986403a0e778f3003ce7f18b322e797f68e764ee1fcb587fec66510537c185270f4fd78b40b3
6
+ metadata.gz: f4e2f11e879c4c6af1fc88a1df84cc8ce2bb373ba7c1c7c8ce2674e1997a793c361ecd77fe9d539002e387aebae8e66cfe48d186a4ba889da2f7e978776c8b4a
7
+ data.tar.gz: dcaa77759c298e69e5400b72cf0cddcdb479430e21786a15a020c6b647393fd773c9359aa950a38b127714644aa398708d0756220c159bb3dc5693cc620d3cc7
data/CHANGELOG.md CHANGED
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
9
9
  ### Changed
10
10
  ### Fixed
11
11
 
12
+ ## [0.3.4]
13
+ ### Fixed
14
+ - cover multiple possible returns types of display_class
15
+
12
16
  ## [0.3.3]
13
17
  ### Fixed
14
18
  - Fix unwrap_class_name, it was wrongly expecting an instance not a class.
@@ -74,7 +74,7 @@ module Sidekiq
74
74
  # The class name was not unwrapped correctly by the +display_class+ method
75
75
  job.args[0]['arguments'][0..1].join('#')
76
76
  else
77
- display_class
77
+ display_class.to_s
78
78
  end
79
79
  end
80
80
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Instrumental
5
- VERSION = '0.3.3.beta1'
5
+ VERSION = '0.3.4'
6
6
  end
7
7
  end
@@ -69,6 +69,16 @@ RSpec.describe Sidekiq::Instrumental::Middleware::Client do
69
69
  subject
70
70
  end
71
71
  end
72
+
73
+ context 'when the class is not passed as a string' do
74
+ let(:msg) { { 'class' => stub_const('MyClassName', Class.new) } }
75
+
76
+ it 'increments the queued metric for the queue' do
77
+ expect(middleware).to receive(:increment).with("sidekiq.#{queue}.queued")
78
+
79
+ subject
80
+ end
81
+ end
72
82
  end
73
83
 
74
84
  it 'calls display_class to get the class name' do
@@ -89,32 +99,66 @@ RSpec.describe Sidekiq::Instrumental::Middleware::Client do
89
99
  let(:msg) do
90
100
  {
91
101
  'class' => 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper',
92
- 'wrapped' => wrapped_class,
93
- 'args' => [{ 'arguments' => %w[UserMailer confirm_account deliver_now User] }]
102
+ 'wrapped' => passed_class,
103
+ 'args' => args
94
104
  }
95
105
  end
106
+ let(:args) { [] }
96
107
 
97
- context "when sidekiq's wrapped class is set as a String" do
98
- let(:wrapped_class) { 'ActionMailer::DeliveryJob' }
108
+ context "when sidekiq's wrapped class is a mail delivery job" do
109
+ let(:wrapped_class) { stub_const('ActionMailer::DeliveryJob', Class.new) }
110
+ let(:args) { [{ 'arguments' => %w[UserMailer confirm_account deliver_now User] }] }
99
111
 
100
- it 'unwraps the class name and increments the metric' do
101
- expect(middleware)
102
- .to receive(:increment)
103
- .with("sidekiq.#{queue}.user_mailer_confirm_account.queued")
112
+ context 'when passed as a String' do
113
+ let(:passed_class) { wrapped_class.to_s }
104
114
 
105
- subject
115
+ it 'unwraps the class name and increments the metric' do
116
+ expect(middleware)
117
+ .to receive(:increment)
118
+ .with("sidekiq.#{queue}.user_mailer_confirm_account.queued")
119
+
120
+ subject
121
+ end
122
+ end
123
+
124
+ context 'when passed as a Class' do
125
+ let(:passed_class) { wrapped_class }
126
+
127
+ it 'unwraps the class name and increments the metric' do
128
+ expect(middleware)
129
+ .to receive(:increment)
130
+ .with("sidekiq.#{queue}.user_mailer_confirm_account.queued")
131
+
132
+ subject
133
+ end
106
134
  end
107
135
  end
108
136
 
109
- context "when sidekiq's wrapped class is set as a Class" do
110
- let(:wrapped_class) { stub_const('ActionMailer::DeliveryJob', Class.new) }
137
+ context "when sidekiq's wrapped class is not a mail delivery job" do
138
+ let(:wrapped_class) { stub_const('Jobs::Job', Class.new) }
111
139
 
112
- it 'unwraps the class name and increments the metric' do
113
- expect(middleware)
114
- .to receive(:increment)
115
- .with("sidekiq.#{queue}.user_mailer_confirm_account.queued")
140
+ context 'when passed as a String' do
141
+ let(:passed_class) { wrapped_class.to_s }
116
142
 
117
- subject
143
+ it 'unwraps the class name and increments the metric' do
144
+ expect(middleware)
145
+ .to receive(:increment)
146
+ .with("sidekiq.#{queue}.jobs_job.queued")
147
+
148
+ subject
149
+ end
150
+ end
151
+
152
+ context 'when passed as a Class' do
153
+ let(:passed_class) { wrapped_class }
154
+
155
+ it 'unwraps the class name and increments the metric' do
156
+ expect(middleware)
157
+ .to receive(:increment)
158
+ .with("sidekiq.#{queue}.jobs_job.queued")
159
+
160
+ subject
161
+ end
118
162
  end
119
163
  end
120
164
  end
@@ -122,6 +122,16 @@ RSpec.describe Sidekiq::Instrumental::Middleware::Server do
122
122
  subject
123
123
  end
124
124
  end
125
+
126
+ context 'when the class is not passed as a string' do
127
+ let(:msg) { { 'class' => stub_const('MyClassName', Class.new) } }
128
+
129
+ it 'increments the queued metric for the queue' do
130
+ expect(middleware).to receive(:increment).with("sidekiq.#{queue}.processed")
131
+
132
+ subject
133
+ end
134
+ end
125
135
  end
126
136
 
127
137
  it 'gauge elapsed time metric for the class' do
@@ -138,32 +148,66 @@ RSpec.describe Sidekiq::Instrumental::Middleware::Server do
138
148
  let(:msg) do
139
149
  {
140
150
  'class' => 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper',
141
- 'wrapped' => wrapped_class,
142
- 'args' => [{ 'arguments' => %w[UserMailer confirm_account deliver_now User] }]
151
+ 'wrapped' => passed_class,
152
+ 'args' => args
143
153
  }
144
154
  end
155
+ let(:args) { [] }
145
156
 
146
- context "when sidekiq's wrapped class is set as a String" do
147
- let(:wrapped_class) { 'ActionMailer::DeliveryJob' }
157
+ context "when sidekiq's wrapped class is a mail delivery job" do
158
+ let(:wrapped_class) { stub_const('ActionMailer::DeliveryJob', Class.new) }
159
+ let(:args) { [{ 'arguments' => %w[UserMailer confirm_account deliver_now User] }] }
148
160
 
149
- it 'unwraps the class name and increments the metric' do
150
- expect(middleware)
151
- .to receive(:increment)
152
- .with("sidekiq.#{queue}.user_mailer_confirm_account.processed")
161
+ context 'when passed as a String' do
162
+ let(:passed_class) { wrapped_class.to_s }
153
163
 
154
- subject
164
+ it 'unwraps the class name and increments the metric' do
165
+ expect(middleware)
166
+ .to receive(:increment)
167
+ .with("sidekiq.#{queue}.user_mailer_confirm_account.processed")
168
+
169
+ subject
170
+ end
171
+ end
172
+
173
+ context 'when passed as a Class' do
174
+ let(:passed_class) { wrapped_class }
175
+
176
+ it 'unwraps the class name and increments the metric' do
177
+ expect(middleware)
178
+ .to receive(:increment)
179
+ .with("sidekiq.#{queue}.user_mailer_confirm_account.processed")
180
+
181
+ subject
182
+ end
155
183
  end
156
184
  end
157
185
 
158
- context "when sidekiq's wrapped class is set as a Class" do
159
- let(:wrapped_class) { stub_const('ActionMailer::DeliveryJob', Class.new) }
186
+ context "when sidekiq's wrapped class is not a mail delivery job" do
187
+ let(:wrapped_class) { stub_const('Jobs::Job', Class.new) }
160
188
 
161
- it 'unwraps the class name and increments the metric' do
162
- expect(middleware)
163
- .to receive(:increment)
164
- .with("sidekiq.#{queue}.user_mailer_confirm_account.processed")
189
+ context 'when passed as a String' do
190
+ let(:passed_class) { wrapped_class.to_s }
165
191
 
166
- subject
192
+ it 'unwraps the class name and increments the metric' do
193
+ expect(middleware)
194
+ .to receive(:increment)
195
+ .with("sidekiq.#{queue}.jobs_job.processed")
196
+
197
+ subject
198
+ end
199
+ end
200
+
201
+ context 'when passed as a Class' do
202
+ let(:passed_class) { wrapped_class }
203
+
204
+ it 'unwraps the class name and increments the metric' do
205
+ expect(middleware)
206
+ .to receive(:increment)
207
+ .with("sidekiq.#{queue}.jobs_job.processed")
208
+
209
+ subject
210
+ end
167
211
  end
168
212
  end
169
213
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-instrumental
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3.beta1
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Rudd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-19 00:00:00.000000000 Z
11
+ date: 2022-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: instrumental_agent
@@ -194,9 +194,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
194
  version: '2.3'
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  requirements:
197
- - - ">"
197
+ - - ">="
198
198
  - !ruby/object:Gem::Version
199
- version: 1.3.1
199
+ version: '0'
200
200
  requirements: []
201
201
  rubygems_version: 3.1.6
202
202
  signing_key: