sidekiq-instrument 0.5.3 → 0.5.5

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: 8c5ff8d26009611bbdb4c3282c9e6988d2d3bf755c8029095ee6ce9939810db3
4
- data.tar.gz: fa29960d6ac51cb3d22f230b8c6275bb893a89366ae8710091aa239e4de2829f
3
+ metadata.gz: f9a0f783ab0e59fc566b949266b79f362a76d7c99cd15886e5d09b01b26f08f0
4
+ data.tar.gz: b7d615af7a4884543ef3e7a5a585186fa0f93f1627fe9f5eac0576835b449136
5
5
  SHA512:
6
- metadata.gz: 926b9162dc1910c198c441faff6b87c036c8a9d87f91d35159af0ea0c09091971d27e40adba8a87732667f88fd4c132284b14400306ce798282460dd2b6c0445
7
- data.tar.gz: 662b3f4b9fe31c355831a24cd43f8cd7c98fd5c2f08cc286e38bfbf5747cd40ef8b9775fa26d36069b0f76a175002a1ff17b6f73d9e0922e5e58fa185e58e354
6
+ metadata.gz: 95343856da7a9cad0f41dbcfe4731a4837782ac13bf9f4b515579f45f4326b7f25e4d7c85c5e1ea7ef519f271cd1b6aa7f16c62c89e9c02acb412b1b321e57f8
7
+ data.tar.gz: dfd0394b47aba69c43e58feabd778dc38091f8e0e61a4c75086c23bf7504fcb294881f3102bbe4de8dbd85223ecf024bdc27721a615bfa6f46df298153a7c186
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Instrument
3
- VERSION = "0.5.3"
3
+ VERSION = '0.5.5'
4
4
  end
5
5
  end
@@ -9,10 +9,10 @@ module Sidekiq::Instrument
9
9
  # (i.e. the metrics will reported as :processed, :workers, :pending, and :failed).
10
10
  # Feel free to override.
11
11
  METRIC_NAMES = {
12
- processed: nil,
12
+ processed: nil,
13
13
  workers_size: :workers,
14
- enqueued: :pending,
15
- failed: nil
14
+ enqueued: :pending,
15
+ failed: nil
16
16
  }
17
17
 
18
18
  def perform
@@ -25,21 +25,39 @@ module Sidekiq::Instrument
25
25
  Statter.dogstatsd&.gauge("sidekiq.#{stat}", info.send(method))
26
26
  end
27
27
 
28
- working = Sidekiq::ProcessSet.new.select { |p| p[:busy] == 1 }.count
28
+ working = Sidekiq::Workers.new.count
29
29
  Statter.statsd.gauge('shared.sidekiq.stats.working', working)
30
30
  Statter.dogstatsd&.gauge('sidekiq.working', working)
31
31
 
32
- info.queues.each do |name, size|
33
- Statter.statsd.gauge("shared.sidekiq.#{name}.size", size)
34
- Statter.dogstatsd&.gauge('sidekiq.queue.size', size, tags: ["queue:#{name}"])
35
- end
36
-
37
32
  Sidekiq::Queue.all.each do |queue|
33
+ Statter.statsd.gauge("shared.sidekiq.#{queue.name}.size", queue.size)
34
+ Statter.dogstatsd&.gauge('sidekiq.queue.size', queue.size, tags: dd_tags(queue))
35
+
38
36
  Statter.statsd.gauge("shared.sidekiq.#{queue.name}.latency", queue.latency)
39
- Statter.dogstatsd&.gauge('sidekiq.queue.latency', queue.latency, tags: ["queue:#{queue.name}"])
37
+ Statter.dogstatsd&.gauge('sidekiq.queue.latency', queue.latency, tags: dd_tags(queue))
40
38
  end
41
39
 
42
40
  Statter.dogstatsd&.flush(sync: true)
43
41
  end
42
+
43
+ private
44
+
45
+ # @param [Sidekiq::Queue] queue used for stats emission
46
+ # @return [Array<String>] an array of tags
47
+ # @example this method can be override to add more tags
48
+ # class MyStatsWorker < Sidekiq::Instrument::Worker
49
+ # private
50
+ #
51
+ # def dd_tags(queue)
52
+ # custom_tags = []
53
+ # queue_type = queue.name.match?(/readonly$/) ? 'read_only' : 'regular'
54
+ # custom_tags << "queue_type:#{queue_type}"
55
+ #
56
+ # super(queue) | custom_tags
57
+ # end
58
+ # end
59
+ def dd_tags(queue)
60
+ ["queue:#{queue.name}"]
61
+ end
44
62
  end
45
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-instrument
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loan Application Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-19 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq