|
262 | 262 | end
|
263 | 263 | end
|
264 | 264 |
|
| 265 | + context "with a custom interval of less than 60" do |
| 266 | + subject(:publisher) { Sidekiq::CloudWatchMetrics::Publisher.new(client: client, interval: 30) } |
| 267 | + |
| 268 | + it "passes sets a storage resolution of 1" do |
| 269 | + Timecop.freeze(now = Time.now) do |
| 270 | + publisher.publish |
| 271 | + |
| 272 | + expect(client).to have_received(:put_metric_data).with( |
| 273 | + namespace: "Sidekiq", |
| 274 | + metric_data: including( |
| 275 | + { |
| 276 | + metric_name: "ProcessedJobs", |
| 277 | + timestamp: now, |
| 278 | + value: 123, |
| 279 | + unit: "Count", |
| 280 | + storage_resolution: 1, |
| 281 | + }, |
| 282 | + { |
| 283 | + metric_name: "FailedJobs", |
| 284 | + timestamp: now, |
| 285 | + value: 456, |
| 286 | + unit: "Count", |
| 287 | + storage_resolution: 1, |
| 288 | + }, |
| 289 | + { |
| 290 | + metric_name: "QueueSize", |
| 291 | + dimensions: [{name: "QueueName", value: "bar"}], |
| 292 | + timestamp: now, |
| 293 | + value: 2, |
| 294 | + unit: "Count", |
| 295 | + storage_resolution: 1, |
| 296 | + }, |
| 297 | + { |
| 298 | + metric_name: "QueueLatency", |
| 299 | + dimensions: [{name: "QueueName", value: "bar"}], |
| 300 | + timestamp: now, |
| 301 | + value: 1.23, |
| 302 | + unit: "Seconds", |
| 303 | + storage_resolution: 1, |
| 304 | + }, |
| 305 | + ) |
| 306 | + ) |
| 307 | + end |
| 308 | + end |
| 309 | + end |
| 310 | + |
| 311 | + context "with a custom interval of more than 60" do |
| 312 | + subject(:publisher) { Sidekiq::CloudWatchMetrics::Publisher.new(client: client, interval: 120) } |
| 313 | + |
| 314 | + it "doesn't pass a storage resolution" do |
| 315 | + Timecop.freeze(now = Time.now) do |
| 316 | + publisher.publish |
| 317 | + |
| 318 | + expect(client).to have_received(:put_metric_data).with( |
| 319 | + namespace: "Sidekiq", |
| 320 | + metric_data: including( |
| 321 | + { |
| 322 | + metric_name: "ProcessedJobs", |
| 323 | + timestamp: now, |
| 324 | + value: 123, |
| 325 | + unit: "Count", |
| 326 | + }, |
| 327 | + { |
| 328 | + metric_name: "FailedJobs", |
| 329 | + timestamp: now, |
| 330 | + value: 456, |
| 331 | + unit: "Count", |
| 332 | + }, |
| 333 | + { |
| 334 | + metric_name: "QueueSize", |
| 335 | + dimensions: [{name: "QueueName", value: "bar"}], |
| 336 | + timestamp: now, |
| 337 | + value: 2, |
| 338 | + unit: "Count", |
| 339 | + }, |
| 340 | + { |
| 341 | + metric_name: "QueueLatency", |
| 342 | + dimensions: [{name: "QueueName", value: "bar"}], |
| 343 | + timestamp: now, |
| 344 | + value: 1.23, |
| 345 | + unit: "Seconds", |
| 346 | + }, |
| 347 | + ) |
| 348 | + ) |
| 349 | + end |
| 350 | + end |
| 351 | + end |
| 352 | + |
265 | 353 | context "with lots of queues" do
|
266 | 354 | let(:queues) { 10.times.each_with_object({}) { |i, hash| hash["queue#{i}"] = double(size: 1, latency: 1.23) } }
|
267 | 355 |
|
|
0 commit comments