sidekiq-instrument 0.7.3 → 0.7.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: 7c79cacef1cb058038cfd3c55495349dbbd4b4c023114bb4760e83868647a9b1
4
- data.tar.gz: c2c1ad52812042a210fc7549b48520977ec33836b850b17110002d3b23d442d4
3
+ metadata.gz: 80c86d5df7ca90b39edcb4c60ca4a92e1c1e128584bbc78be60f4dd6f75b3d19
4
+ data.tar.gz: 5e6807e9553c968e8ddb61f1cc7061e8798d4e1aca6257ebab86eb29bfd5f3d2
5
5
  SHA512:
6
- metadata.gz: c586597549a8eb0a7002ea2f1b290737a39d5fb08f66565f613c5f77448c32027f961b44a3c2cd743f05f80f0bdaf3e4fcc8297357e8b3f6eb43bd3b25d0c14a
7
- data.tar.gz: 88d1aee1549d0189be4c6e71cefdb6dc7d975f932c9e47b20ce7b9245646f2eb01d29e2b079e300197afa028888c9e26c2e5eefbebed4fdf8d20013170667fb4
6
+ metadata.gz: dca33f186fe4ca74db99a2fe8836047a5bfd499f435c28ebd20601835e43553cabb5565713ea17c2d7e08a5e68bb516622033674dfe5ef96496c8ff56b07ee79
7
+ data.tar.gz: b41c82a0b3d99eaea85fcbf00bcd631a04dc69edd152a849066866dc132ded2ceb9514277f5842fe33944c0c0141016672ab2fca20d26de5130e3d7f56c22e45
data/README.md CHANGED
@@ -75,16 +75,19 @@ Sidekiq::Instrument::WorkerMetrics.namespace = <APP_NAME>
75
75
  ## StatsD Keys
76
76
  For each job, the following metrics will be reported:
77
77
 
78
- 1. **shared.sidekiq._queue_._job_.enqueue**: counter incremented each time a
78
+ 1. **shared.sidekiq._queue_._job_.schedule**: counter incremented each time a
79
+ job is scheduled to be pushed onto the queue later.
80
+ 2. **shared.sidekiq._queue_._job_.enqueue**: counter incremented each time a
79
81
  job is pushed onto the queue.
80
- 2. **shared.sidekiq._queue_._job_.dequeue**: counter incremented just before
82
+ 3. **shared.sidekiq._queue_._job_.dequeue**: counter incremented just before
81
83
  worker begins performing a job.
82
- 3. **shared.sidekiq._queue_._job_.runtime**: timer of the total time spent
84
+ 4. **shared.sidekiq._queue_._job_.success**: counter incremented each time a job succeeds.
85
+ 5. **shared.sidekiq._queue_._job_.runtime**: timer of the total time spent
83
86
  in `perform`, in milliseconds.
84
- 4. **shared.sidekiq._queue_._job_.error**: counter incremented each time a
87
+ 6. **shared.sidekiq._queue_._job_.error**: counter incremented each time a
85
88
  job fails.
86
89
 
87
- For job retry attempts, the above 4 metrics will still be reported but the enqueue/dequeue metrics
90
+ For job retry attempts, metrics 2-5 will still be reported but the enqueue/dequeue metrics
88
91
  will have a `.retry` appended:
89
92
 
90
93
  1. **shared.sidekiq._queue_._job_.enqueue.retry**
@@ -103,13 +106,16 @@ For each worker, the following metrics and tags will be reported:
103
106
  ## DogStatsD Keys
104
107
  For each job, the following metrics and tags will be reported:
105
108
 
106
- 1. **sidekiq.enqueue (tags: {queue: _queue_, worker: _job_})**: counter incremented each time a
109
+ 1. **sidekiq.schedule (tags: {queue: _queue_, worker: _job_})**: counter incremented each time a
110
+ job is scheduled to be pushed onto the queue later.
111
+ 2. **sidekiq.enqueue (tags: {queue: _queue_, worker: _job_})**: counter incremented each time a
107
112
  job is pushed onto the queue.
108
- 2. **sidekiq.dequeue (tags: {queue: _queue_, worker: _job_})**: counter incremented just before
113
+ 3. **sidekiq.dequeue (tags: {queue: _queue_, worker: _job_})**: counter incremented just before
109
114
  worker begins performing a job.
110
- 3. **sidekiq.runtime (tags: {queue: _queue_, worker: _job_})**: timer of the total time spent
115
+ 4. **sidekiq.success (tags: {queue: _queue_, worker: _job_})**: counter incremented each time a job succeeds.
116
+ 5. **sidekiq.runtime (tags: {queue: _queue_, worker: _job_})**: timer of the total time spent
111
117
  in `perform`, in milliseconds.
112
- 4. **sidekiq.error (tags: {queue: _queue_, worker: _job_})**: counter incremented each time a
118
+ 6. **sidekiq.error (tags: {queue: _queue_, worker: _job_, error: _errorclass_})**: counter incremented each time a
113
119
  job fails.
114
120
 
115
121
  For job retry attempts, the above 4 metrics will still be reported but the enqueue/dequeue metrics
@@ -127,7 +133,7 @@ For each worker, the following metrics and tags will be reported:
127
133
 
128
134
  ## Worker
129
135
 
130
- **WARNING: The metrics reported by this Worker are currently inaccurate.**
136
+ **WARNING: The Redis count metrics reported by this Worker are currently inaccurate.**
131
137
 
132
138
  There is a worker, `Sidekiq::Instrument::Worker`, that submits gauges
133
139
  for various interesting statistics; namely, the bulk of the information in `Sidekiq::Stats`
@@ -12,12 +12,18 @@ module Sidekiq::Instrument
12
12
  klass = Object.const_get(worker_class.to_s)
13
13
  class_instance = klass.new
14
14
 
15
- # This is needed because the ClientMiddleware is called twice for scheduled jobs
16
- # - Once when it gets scheduled
17
- # - Once when it gets dequeued for processing
18
- # We only want to increment the enqueue metric when the job is scheduled and
19
- # Sidekiq::Context.current[:class] is only ever set when the job is scheduled
20
- if Sidekiq::Context.current[:class].present?
15
+ # Depending on the type of perform called, this method can be hit either
16
+ # once or twice for the same Job ID.
17
+ #
18
+ # perform_async:
19
+ # - once when it is enqueued, with no job['at'] key
20
+ # perform_in:
21
+ # - once when it is scheduled, with job['at'] key
22
+ # - once when it is enqueued, without job['at'] key
23
+ if job['at'].present?
24
+ Statter.statsd.increment(metric_name(class_instance, 'schedule'))
25
+ Statter.dogstatsd&.increment('sidekiq.schedule', worker_dog_options(class_instance, job))
26
+ else
21
27
  WorkerMetrics.trace_workers_increment_counter(klass.name.underscore)
22
28
  Statter.statsd.increment(metric_name(class_instance, 'enqueue'))
23
29
  Statter.dogstatsd&.increment('sidekiq.enqueue', worker_dog_options(class_instance, job))
@@ -17,6 +17,8 @@ module Sidekiq::Instrument
17
17
  execution_time_ms = (Time.now - start_time) * 1000
18
18
  Statter.dogstatsd&.timing('sidekiq.runtime', execution_time_ms, worker_dog_options(worker, job))
19
19
  Statter.statsd.measure(metric_name(worker, 'runtime'), execution_time_ms)
20
+ Statter.dogstatsd&.increment('sidekiq.success', worker_dog_options(worker, job))
21
+ Statter.statsd.increment(metric_name(worker, 'success'))
20
22
  rescue Exception => e
21
23
  dd_options = worker_dog_options(worker, job)
22
24
  dd_options[:tags] << "error:#{e.class.name}"
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Instrument
3
- VERSION = '0.7.3'
3
+ VERSION = '0.7.5'
4
4
  end
5
5
  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.7.3
4
+ version: 0.7.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: 2024-09-23 00:00:00.000000000 Z
11
+ date: 2024-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq