sidekiq-cloudwatchmetrics 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +134 -1
- data/lib/sidekiq/cloudwatchmetrics.rb +192 -86
- metadata +7 -24
- checksums.yaml.gz.sig +0 -1
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37e77e47a5d947548c5fe5a2ea3ee53ddadc2fd49c1c3bd13c4048974a168ad4
|
|
4
|
+
data.tar.gz: '084b604afc61288be5f566b83623e04da1889f0968c1df8c940c72536f3fa16b'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f2ffdf72ae515cff7c6a13b97f8c9e5cf36696aba2fcacf32972976dd753e1f93c4f18b8663f50d2f3bd11c5fcc4a4885ae94164eafffa818ab9bd6aa1ccf402
|
|
7
|
+
data.tar.gz: 65b5f257361e66a2c48d10e074b13b09b61ea6087b47c83e8cfc7890300f46e3c1ea06f1dbb51d18d68031d339b316550923398b8fe042bf5bdfa7d9bea2b14b
|
data/README.md
CHANGED
|
@@ -27,6 +27,127 @@ require "sidekiq/cloudwatchmetrics"
|
|
|
27
27
|
Sidekiq::CloudWatchMetrics.enable!
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
### Configuration
|
|
31
|
+
|
|
32
|
+
By default, all metrics are published to CloudWatch. If you want to reduce costs by only publishing specific metrics, you can configure which metrics to enable using an opt-in approach:
|
|
33
|
+
|
|
34
|
+
```ruby
|
|
35
|
+
# config/initializers/sidekiq.rb
|
|
36
|
+
require "sidekiq"
|
|
37
|
+
require "sidekiq/cloudwatchmetrics"
|
|
38
|
+
|
|
39
|
+
# Configure which metrics to publish (opt-in)
|
|
40
|
+
Sidekiq::CloudWatchMetrics.configure do |config|
|
|
41
|
+
# Enable only the metrics you need
|
|
42
|
+
config.enable_metric :queue_size # Enable QueueSize metric
|
|
43
|
+
config.enable_metric :queue_latency # Enable QueueLatency metric
|
|
44
|
+
config.enable_metric :utilization # Enable Utilization metric
|
|
45
|
+
|
|
46
|
+
# Or enable multiple metrics at once
|
|
47
|
+
config.enable_metrics :capacity, :processes
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Then enable CloudWatch metrics with your options
|
|
51
|
+
Sidekiq::CloudWatchMetrics.enable!(
|
|
52
|
+
namespace: "Sidekiq-Production",
|
|
53
|
+
interval: 60
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Available Metrics
|
|
58
|
+
|
|
59
|
+
Unknown metric keys raise `ArgumentError` when you configure them.
|
|
60
|
+
|
|
61
|
+
| Metric Key | CloudWatch Metric Name | Description |
|
|
62
|
+
|------------|----------------------|-------------|
|
|
63
|
+
| `:processed_jobs` | ProcessedJobs | Total number of processed jobs |
|
|
64
|
+
| `:failed_jobs` | FailedJobs | Total number of failed jobs |
|
|
65
|
+
| `:enqueued_jobs` | EnqueuedJobs | Number of jobs currently enqueued |
|
|
66
|
+
| `:scheduled_jobs` | ScheduledJobs | Number of jobs scheduled for future |
|
|
67
|
+
| `:retry_jobs` | RetryJobs | Number of jobs pending retry |
|
|
68
|
+
| `:dead_jobs` | DeadJobs | Number of jobs in the dead set |
|
|
69
|
+
| `:queue_size` | QueueSize | Size of each queue (per queue metric) |
|
|
70
|
+
| `:queue_latency` | QueueLatency | Latency of each queue in seconds (per queue metric) |
|
|
71
|
+
| `:default_queue_latency` | DefaultQueueLatency | Overall queue latency |
|
|
72
|
+
| `:workers` | Workers | Number of busy workers |
|
|
73
|
+
| `:processes` | Processes | Number of Sidekiq processes |
|
|
74
|
+
| `:capacity` | Capacity | Total worker capacity |
|
|
75
|
+
| `:utilization` | Utilization | Percentage utilization (busy/capacity) |
|
|
76
|
+
|
|
77
|
+
#### Common Configuration Examples
|
|
78
|
+
|
|
79
|
+
##### For Autoscaling by Queue Metrics
|
|
80
|
+
If you're using CloudWatch metrics for autoscaling based on queue size or latency:
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
Sidekiq::CloudWatchMetrics.configure do |config|
|
|
84
|
+
config.enable_metrics :queue_size, :queue_latency
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
Sidekiq::CloudWatchMetrics.enable!
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
##### For Process Monitoring
|
|
91
|
+
Focus on process health and utilization metrics:
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
Sidekiq::CloudWatchMetrics.configure do |config|
|
|
95
|
+
config.enable_metrics :utilization, :capacity, :processes, :workers
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
Sidekiq::CloudWatchMetrics.enable!
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
##### For Job Processing Tracking
|
|
102
|
+
Track job processing statistics:
|
|
103
|
+
|
|
104
|
+
```ruby
|
|
105
|
+
Sidekiq::CloudWatchMetrics.configure do |config|
|
|
106
|
+
config.enable_metrics :processed_jobs, :failed_jobs, :retry_jobs, :dead_jobs
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
Sidekiq::CloudWatchMetrics.enable!
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
##### Minimal Setup for Cost Savings
|
|
113
|
+
If you only need specific metrics for autoscaling:
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
Sidekiq::CloudWatchMetrics.configure do |config|
|
|
117
|
+
# Only enable the exact metrics your autoscaling policies use
|
|
118
|
+
config.enable_metrics :queue_size, :queue_latency, :utilization
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
Sidekiq::CloudWatchMetrics.enable!(namespace: "Sidekiq-Production")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### Backward Compatibility
|
|
125
|
+
|
|
126
|
+
If you don't configure any metrics explicitly, ALL metrics will be published (default behavior). This ensures existing installations continue to work without any changes:
|
|
127
|
+
|
|
128
|
+
```ruby
|
|
129
|
+
# Without configuration - all metrics enabled (backward compatible)
|
|
130
|
+
Sidekiq::CloudWatchMetrics.enable!
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### Startup Logging
|
|
134
|
+
|
|
135
|
+
The gem will log the active metrics configuration on startup to help you verify your configuration:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
INFO: Started Sidekiq CloudWatch Metrics Publisher
|
|
139
|
+
INFO: Metrics configuration: Enabled metrics: capacity, queue_latency, queue_size, utilization
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Or if using defaults:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
INFO: Started Sidekiq CloudWatch Metrics Publisher
|
|
146
|
+
INFO: Metrics configuration: All metrics enabled (default)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Additional Options
|
|
150
|
+
|
|
30
151
|
By default this assumes you're running on an EC2 instance with an instance role
|
|
31
152
|
that can publish CloudWatch metrics, or that you've supplied AWS credentials
|
|
32
153
|
through environment variables that aws-sdk expects. You can also explicitly
|
|
@@ -54,7 +175,19 @@ Sidekiq::CloudWatchMetrics.enable!(interval: 30)
|
|
|
54
175
|
|
|
55
176
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
56
177
|
|
|
57
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
178
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
179
|
+
|
|
180
|
+
### Releasing
|
|
181
|
+
|
|
182
|
+
Bump the version in `sidekiq-cloudwatchmetrics.gemspec` and land the change on `main`.
|
|
183
|
+
After CI passes, run [Release gem](https://github.com/sj26/sidekiq-cloudwatchmetrics/actions/workflows/release.yml) on `main`.
|
|
184
|
+
The workflow creates the `v<version>` tag, publishes to RubyGems, then creates a GitHub release with generated notes.
|
|
185
|
+
|
|
186
|
+
The workflow uses [RubyGems Trusted Publishing](https://guides.rubygems.org/trusted-publishing/).
|
|
187
|
+
Register `sj26/sidekiq-cloudwatchmetrics` with workflow filename `release.yml` and environment `release` on RubyGems.
|
|
188
|
+
Restrict the matching GitHub environment to the `main` branch. No RubyGems API key is needed.
|
|
189
|
+
|
|
190
|
+
If the gem is on RubyGems but the GitHub release step fails, create the GitHub release from the existing tag instead of publishing the gem again.
|
|
58
191
|
|
|
59
192
|
## Contributing
|
|
60
193
|
|
|
@@ -6,29 +6,85 @@ require "sidekiq/api"
|
|
|
6
6
|
require "aws-sdk-cloudwatch"
|
|
7
7
|
|
|
8
8
|
module Sidekiq::CloudWatchMetrics
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
class MetricsConfig
|
|
10
|
+
METRIC_KEYS = %i[
|
|
11
|
+
processed_jobs failed_jobs enqueued_jobs scheduled_jobs retry_jobs dead_jobs
|
|
12
|
+
workers processes default_queue_latency capacity utilization queue_size queue_latency
|
|
13
|
+
].freeze
|
|
14
|
+
private_constant :METRIC_KEYS
|
|
15
|
+
|
|
16
|
+
attr_reader :enabled_metrics
|
|
17
|
+
|
|
18
|
+
def initialize
|
|
19
|
+
@enabled_metrics = Set.new
|
|
20
|
+
@all_enabled = true # backward compatibility - all metrics enabled by default
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def enable_metric(metric)
|
|
24
|
+
enable_metrics(metric)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def enable_metrics(*metrics)
|
|
28
|
+
keys = metrics.map(&:to_sym)
|
|
29
|
+
unknown = keys - METRIC_KEYS
|
|
30
|
+
raise ArgumentError, "Unknown metric keys: #{unknown.join(', ')}" unless unknown.empty?
|
|
31
|
+
|
|
32
|
+
@all_enabled = false unless keys.empty?
|
|
33
|
+
@enabled_metrics.merge(keys)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def metric_enabled?(metric)
|
|
37
|
+
@all_enabled || @enabled_metrics.include?(metric.to_sym)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def all_enabled?
|
|
41
|
+
@all_enabled
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def to_s
|
|
45
|
+
if @all_enabled
|
|
46
|
+
"All metrics enabled (default)"
|
|
19
47
|
else
|
|
20
|
-
|
|
21
|
-
config.on(:startup) do
|
|
22
|
-
publisher.start
|
|
23
|
-
end
|
|
48
|
+
"Enabled metrics: #{@enabled_metrics.to_a.sort.join(', ')}"
|
|
24
49
|
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
25
52
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
53
|
+
class << self
|
|
54
|
+
attr_accessor :metrics_config
|
|
55
|
+
|
|
56
|
+
def configure
|
|
57
|
+
self.metrics_config ||= MetricsConfig.new
|
|
58
|
+
yield(metrics_config) if block_given?
|
|
59
|
+
metrics_config
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def enable!(**kwargs)
|
|
63
|
+
Sidekiq.configure_server do |config|
|
|
64
|
+
# Use configured metrics or default (all enabled)
|
|
65
|
+
kwargs[:metrics_config] = metrics_config || MetricsConfig.new
|
|
66
|
+
publisher = Publisher.new(config: config, **kwargs)
|
|
67
|
+
|
|
68
|
+
# Sidekiq enterprise has a globally unique leader thread, making it
|
|
69
|
+
# easier to publish the cluster-wide metrics from one place.
|
|
70
|
+
if defined?(Sidekiq::Enterprise)
|
|
71
|
+
config.on(:leader) do
|
|
72
|
+
publisher.start
|
|
73
|
+
end
|
|
74
|
+
else
|
|
75
|
+
# Otherwise pubishing from every node doesn't hurt, it's just wasteful
|
|
76
|
+
config.on(:startup) do
|
|
77
|
+
publisher.start
|
|
78
|
+
end
|
|
79
|
+
end
|
|
29
80
|
|
|
30
|
-
|
|
31
|
-
|
|
81
|
+
config.on(:quiet) do
|
|
82
|
+
publisher.quiet if publisher.running?
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
config.on(:shutdown) do
|
|
86
|
+
publisher.stop if publisher.running?
|
|
87
|
+
end
|
|
32
88
|
end
|
|
33
89
|
end
|
|
34
90
|
end
|
|
@@ -55,7 +111,7 @@ module Sidekiq::CloudWatchMetrics
|
|
|
55
111
|
end
|
|
56
112
|
end
|
|
57
113
|
|
|
58
|
-
def initialize(config: default_config, client: Aws::CloudWatch::Client.new, namespace: "Sidekiq", process_metrics: true, additional_dimensions: {}, interval: DEFAULT_INTERVAL)
|
|
114
|
+
def initialize(config: default_config, client: Aws::CloudWatch::Client.new, namespace: "Sidekiq", process_metrics: true, additional_dimensions: {}, interval: DEFAULT_INTERVAL, metrics_config: nil)
|
|
59
115
|
# Required by Sidekiq::Component (in sidekiq 6.5+)
|
|
60
116
|
@config = config
|
|
61
117
|
|
|
@@ -64,6 +120,7 @@ module Sidekiq::CloudWatchMetrics
|
|
|
64
120
|
@namespace = namespace
|
|
65
121
|
@process_metrics = process_metrics
|
|
66
122
|
@additional_dimensions = additional_dimensions.map { |k, v| {name: k.to_s, value: v.to_s} }
|
|
123
|
+
@metrics_config = metrics_config || MetricsConfig.new
|
|
67
124
|
end
|
|
68
125
|
|
|
69
126
|
def start
|
|
@@ -79,6 +136,7 @@ module Sidekiq::CloudWatchMetrics
|
|
|
79
136
|
|
|
80
137
|
def run
|
|
81
138
|
logger.info { "Started Sidekiq CloudWatch Metrics Publisher" }
|
|
139
|
+
logger.info { "Metrics configuration: #{@metrics_config}" }
|
|
82
140
|
|
|
83
141
|
# Publish stats every @interval_s seconds, sleeping as required between runs
|
|
84
142
|
now = Time.now.to_f
|
|
@@ -106,109 +164,150 @@ module Sidekiq::CloudWatchMetrics
|
|
|
106
164
|
processes = Sidekiq::ProcessSet.new.to_enum(:each).to_a
|
|
107
165
|
queues = stats.queues
|
|
108
166
|
|
|
109
|
-
metrics = [
|
|
110
|
-
|
|
167
|
+
metrics = []
|
|
168
|
+
|
|
169
|
+
# Job metrics
|
|
170
|
+
if @metrics_config.metric_enabled?(:processed_jobs)
|
|
171
|
+
metrics << {
|
|
111
172
|
metric_name: "ProcessedJobs",
|
|
112
173
|
timestamp: now,
|
|
113
174
|
value: stats.processed,
|
|
114
175
|
unit: "Count",
|
|
115
|
-
}
|
|
116
|
-
|
|
176
|
+
}
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
if @metrics_config.metric_enabled?(:failed_jobs)
|
|
180
|
+
metrics << {
|
|
117
181
|
metric_name: "FailedJobs",
|
|
118
182
|
timestamp: now,
|
|
119
183
|
value: stats.failed,
|
|
120
184
|
unit: "Count",
|
|
121
|
-
}
|
|
122
|
-
|
|
185
|
+
}
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
if @metrics_config.metric_enabled?(:enqueued_jobs)
|
|
189
|
+
metrics << {
|
|
123
190
|
metric_name: "EnqueuedJobs",
|
|
124
191
|
timestamp: now,
|
|
125
192
|
value: stats.enqueued,
|
|
126
193
|
unit: "Count",
|
|
127
|
-
}
|
|
128
|
-
|
|
194
|
+
}
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
if @metrics_config.metric_enabled?(:scheduled_jobs)
|
|
198
|
+
metrics << {
|
|
129
199
|
metric_name: "ScheduledJobs",
|
|
130
200
|
timestamp: now,
|
|
131
201
|
value: stats.scheduled_size,
|
|
132
202
|
unit: "Count",
|
|
133
|
-
}
|
|
134
|
-
|
|
203
|
+
}
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
if @metrics_config.metric_enabled?(:retry_jobs)
|
|
207
|
+
metrics << {
|
|
135
208
|
metric_name: "RetryJobs",
|
|
136
209
|
timestamp: now,
|
|
137
210
|
value: stats.retry_size,
|
|
138
211
|
unit: "Count",
|
|
139
|
-
}
|
|
140
|
-
|
|
212
|
+
}
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
if @metrics_config.metric_enabled?(:dead_jobs)
|
|
216
|
+
metrics << {
|
|
141
217
|
metric_name: "DeadJobs",
|
|
142
218
|
timestamp: now,
|
|
143
219
|
value: stats.dead_size,
|
|
144
220
|
unit: "Count",
|
|
145
|
-
}
|
|
146
|
-
|
|
221
|
+
}
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Process metrics
|
|
225
|
+
if @metrics_config.metric_enabled?(:workers)
|
|
226
|
+
metrics << {
|
|
147
227
|
metric_name: "Workers",
|
|
148
228
|
timestamp: now,
|
|
149
229
|
value: stats.workers_size,
|
|
150
230
|
unit: "Count",
|
|
151
|
-
}
|
|
152
|
-
|
|
231
|
+
}
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
if @metrics_config.metric_enabled?(:processes)
|
|
235
|
+
metrics << {
|
|
153
236
|
metric_name: "Processes",
|
|
154
237
|
timestamp: now,
|
|
155
238
|
value: stats.processes_size,
|
|
156
239
|
unit: "Count",
|
|
157
|
-
}
|
|
158
|
-
|
|
240
|
+
}
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
if @metrics_config.metric_enabled?(:default_queue_latency)
|
|
244
|
+
metrics << {
|
|
159
245
|
metric_name: "DefaultQueueLatency",
|
|
160
246
|
timestamp: now,
|
|
161
247
|
value: stats.default_queue_latency,
|
|
162
248
|
unit: "Seconds",
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
metric_name: "Capacity",
|
|
166
|
-
timestamp: now,
|
|
167
|
-
value: calculate_capacity(processes),
|
|
168
|
-
unit: "Count",
|
|
169
|
-
},
|
|
170
|
-
]
|
|
171
|
-
|
|
172
|
-
utilization = calculate_utilization(processes) * 100.0
|
|
173
|
-
|
|
174
|
-
unless utilization.nan?
|
|
175
|
-
metrics << {
|
|
176
|
-
metric_name: "Utilization",
|
|
177
|
-
timestamp: now,
|
|
178
|
-
value: utilization,
|
|
179
|
-
unit: "Percent",
|
|
180
249
|
}
|
|
181
250
|
end
|
|
182
251
|
|
|
183
|
-
|
|
184
|
-
process["tag"]
|
|
185
|
-
end.each do |(tag, tag_processes)|
|
|
186
|
-
next if tag.nil?
|
|
187
|
-
|
|
188
|
-
tag_dimensions = [{name: "Tag", value: tag}]
|
|
189
|
-
|
|
252
|
+
if @metrics_config.metric_enabled?(:capacity)
|
|
190
253
|
metrics << {
|
|
191
254
|
metric_name: "Capacity",
|
|
192
|
-
dimensions: tag_dimensions,
|
|
193
255
|
timestamp: now,
|
|
194
|
-
value: calculate_capacity(
|
|
256
|
+
value: calculate_capacity(processes),
|
|
195
257
|
unit: "Count",
|
|
196
258
|
}
|
|
259
|
+
end
|
|
197
260
|
|
|
198
|
-
|
|
261
|
+
if @metrics_config.metric_enabled?(:utilization)
|
|
262
|
+
utilization = calculate_utilization(processes) * 100.0
|
|
199
263
|
|
|
200
|
-
unless
|
|
264
|
+
unless utilization.nan?
|
|
201
265
|
metrics << {
|
|
202
266
|
metric_name: "Utilization",
|
|
203
|
-
dimensions: tag_dimensions,
|
|
204
267
|
timestamp: now,
|
|
205
|
-
value:
|
|
268
|
+
value: utilization,
|
|
206
269
|
unit: "Percent",
|
|
207
270
|
}
|
|
208
271
|
end
|
|
209
272
|
end
|
|
210
273
|
|
|
211
|
-
|
|
274
|
+
# Tag-based capacity and utilization metrics
|
|
275
|
+
if @metrics_config.metric_enabled?(:capacity) || @metrics_config.metric_enabled?(:utilization)
|
|
276
|
+
processes.group_by do |process|
|
|
277
|
+
process["tag"]
|
|
278
|
+
end.each do |(tag, tag_processes)|
|
|
279
|
+
next if tag.nil?
|
|
280
|
+
|
|
281
|
+
tag_dimensions = [{name: "Tag", value: tag}]
|
|
282
|
+
|
|
283
|
+
if @metrics_config.metric_enabled?(:capacity)
|
|
284
|
+
metrics << {
|
|
285
|
+
metric_name: "Capacity",
|
|
286
|
+
dimensions: tag_dimensions,
|
|
287
|
+
timestamp: now,
|
|
288
|
+
value: calculate_capacity(tag_processes),
|
|
289
|
+
unit: "Count",
|
|
290
|
+
}
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
if @metrics_config.metric_enabled?(:utilization)
|
|
294
|
+
tag_utilization = calculate_utilization(tag_processes) * 100.0
|
|
295
|
+
|
|
296
|
+
unless tag_utilization.nan?
|
|
297
|
+
metrics << {
|
|
298
|
+
metric_name: "Utilization",
|
|
299
|
+
dimensions: tag_dimensions,
|
|
300
|
+
timestamp: now,
|
|
301
|
+
value: tag_utilization,
|
|
302
|
+
unit: "Percent",
|
|
303
|
+
}
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
# Per-process utilization metrics (controlled by process_metrics flag)
|
|
310
|
+
if @process_metrics && @metrics_config.metric_enabled?(:utilization)
|
|
212
311
|
processes.each do |process|
|
|
213
312
|
process_utilization = process["busy"] / process["concurrency"].to_f * 100.0
|
|
214
313
|
|
|
@@ -230,24 +329,31 @@ module Sidekiq::CloudWatchMetrics
|
|
|
230
329
|
end
|
|
231
330
|
end
|
|
232
331
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
332
|
+
# Queue metrics - both queue_size and queue_latency control these
|
|
333
|
+
if @metrics_config.metric_enabled?(:queue_size) || @metrics_config.metric_enabled?(:queue_latency)
|
|
334
|
+
queues.each do |(queue_name, queue_size)|
|
|
335
|
+
if @metrics_config.metric_enabled?(:queue_size)
|
|
336
|
+
metrics << {
|
|
337
|
+
metric_name: "QueueSize",
|
|
338
|
+
dimensions: [{name: "QueueName", value: queue_name}],
|
|
339
|
+
timestamp: now,
|
|
340
|
+
value: queue_size,
|
|
341
|
+
unit: "Count",
|
|
342
|
+
}
|
|
343
|
+
end
|
|
241
344
|
|
|
242
|
-
|
|
345
|
+
if @metrics_config.metric_enabled?(:queue_latency)
|
|
346
|
+
queue_latency = Sidekiq::Queue.new(queue_name).latency
|
|
243
347
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
348
|
+
metrics << {
|
|
349
|
+
metric_name: "QueueLatency",
|
|
350
|
+
dimensions: [{name: "QueueName", value: queue_name}],
|
|
351
|
+
timestamp: now,
|
|
352
|
+
value: queue_latency,
|
|
353
|
+
unit: "Seconds",
|
|
354
|
+
}
|
|
355
|
+
end
|
|
356
|
+
end
|
|
251
357
|
end
|
|
252
358
|
|
|
253
359
|
unless @additional_dimensions.empty?
|
|
@@ -259,7 +365,7 @@ module Sidekiq::CloudWatchMetrics
|
|
|
259
365
|
# We can only put 20 metrics at a time
|
|
260
366
|
metrics.each_slice(20) do |some_metrics|
|
|
261
367
|
if @interval_s < 60
|
|
262
|
-
|
|
368
|
+
some_metrics.each { |metric| metric.merge!(storage_resolution: 1) }
|
|
263
369
|
end
|
|
264
370
|
@client.put_metric_data(
|
|
265
371
|
namespace: @namespace,
|
metadata
CHANGED
|
@@ -1,33 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sidekiq-cloudwatchmetrics
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Cochran
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
|
-
cert_chain:
|
|
10
|
-
-
|
|
11
|
-
-----BEGIN CERTIFICATE-----
|
|
12
|
-
MIIDKDCCAhCgAwIBAgIBAzANBgkqhkiG9w0BAQsFADA6MQ0wCwYDVQQDDARzajI2
|
|
13
|
-
MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0y
|
|
14
|
-
NDA3MjIwNjA3MjdaFw0yNTA3MjIwNjA3MjdaMDoxDTALBgNVBAMMBHNqMjYxFDAS
|
|
15
|
-
BgoJkiaJk/IsZAEZFgRzajI2MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkq
|
|
16
|
-
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr60Eo/ttCk8GMTMFiPr3GoYMIMFvLak
|
|
17
|
-
xSmTk9YGCB6UiEePB4THSSA5w6IPyeaCF/nWkDp3/BAam0eZMWG1IzYQB23TqIM0
|
|
18
|
-
1xzcNRvFsn0aQoQ00k+sj+G83j3T5OOV5OZIlu8xAChMkQmiPd1NXc6uFv+Iacz7
|
|
19
|
-
kj+CMsI9YUFdNoU09QY0b+u+Rb6wDYdpyvN60YC30h0h1MeYbvYZJx/iZK4XY5zu
|
|
20
|
-
4O/FL2ChjL2CPCpLZW55ShYyrzphWJwLOJe+FJ/ZBl6YXwrzQM9HKnt4titSNvyU
|
|
21
|
-
KzE3L63A3PZvExzLrN9u09kuWLLJfXB2sGOlw3n9t72rJiuBr3/OQQIDAQABozkw
|
|
22
|
-
NzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU99dfRjEKFyczTeIz
|
|
23
|
-
m3ZsDWrNC80wDQYJKoZIhvcNAQELBQADggEBAKcQ+MfpXXDmqboG36O8mXhJZJ8+
|
|
24
|
-
zlUqM1QnoEG8XpH/29py4GzSgs6Sb+v/Z1SEArRDq0r1bKZuWiWxqEDnmSE94+pe
|
|
25
|
-
A0Ct6Pv/paEhQCoPkGQNa74cH4tzkVHIA7WSwRL8wOz5vo++YBKH5H36nNqtLV7s
|
|
26
|
-
kNJYsbeOL/w2icQ4b0w4KYgcs4bd6yrYdgcgsRd2sCYb2XFHjczYqw4iEwuUenNM
|
|
27
|
-
G8WXc9zUMVewWkEjS9s++xFNb/7f4dFNXCoE3pgHjzctt7gYcJVacprsg925LYHO
|
|
28
|
-
WsbnbEow7BPlYOZm3rDIsEYpWqxN0lR8BakO2ToJ5RAHXahFu4K4eJtAsLk=
|
|
29
|
-
-----END CERTIFICATE-----
|
|
30
|
-
date: 1980-01-02 00:00:00.000000000 Z
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
31
12
|
dependencies:
|
|
32
13
|
- !ruby/object:Gem::Dependency
|
|
33
14
|
name: sidekiq
|
|
@@ -150,6 +131,7 @@ homepage: https://github.com/sj26/sidekiq-cloudwatchmetrics
|
|
|
150
131
|
licenses:
|
|
151
132
|
- MIT
|
|
152
133
|
metadata: {}
|
|
134
|
+
post_install_message:
|
|
153
135
|
rdoc_options: []
|
|
154
136
|
require_paths:
|
|
155
137
|
- lib
|
|
@@ -164,7 +146,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
164
146
|
- !ruby/object:Gem::Version
|
|
165
147
|
version: '0'
|
|
166
148
|
requirements: []
|
|
167
|
-
rubygems_version: 3.
|
|
149
|
+
rubygems_version: 3.5.22
|
|
150
|
+
signing_key:
|
|
168
151
|
specification_version: 4
|
|
169
152
|
summary: Publish Sidekiq metrics to AWS CloudWatch
|
|
170
153
|
test_files: []
|
checksums.yaml.gz.sig
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
�E���._$�9)���^��m>P��t���x���©���`�͜���[J�M���� ��G3[�jF�é��؇�C�C�WS������\'\JQ"��Ě�a��g��QӉh1l�2���p"�O���`o9��E�M^+l�E6�s,q��F��6�Z�1����c�Ļ2��=��o+xJ������#`~t�ڳ��� D�y[��C�¿6����A�}��ϙR3Wӗ�{��m6�ö@{`�
|
data.tar.gz.sig
DELETED
|
Binary file
|
metadata.gz.sig
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
�i���ؔJ������������=�G���z6�'�Ю�@&�űpu�;�{�q鏿p��z_�J@ �_84�h<K������1�U�- ���!ϰ����5�wG����W�I��'3���#�d^��M���f�61>�:�x�S��k���ī����07m���==�%��yp[+D��>=�����L�N�"���O�[F���W�~�`:�u+k��� ��}��>����1h4fϖ��a��˶4B
|