sidekiq-cloudwatchmetrics 2.6.0 → 2.8.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
- checksums.yaml.gz.sig +0 -0
- data/README.md +6 -3
- data/lib/sidekiq/cloudwatchmetrics.rb +40 -12
- data.tar.gz.sig +0 -0
- metadata +17 -17
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cc57f884a22e51c089dc46fb2d5717cab59b3e35aa5314d0275eac536013519
|
4
|
+
data.tar.gz: 8926d75fb32f92a4676398cc89b12c595988c08024306a0ad085c707f92e250d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 994bb3093eb6e27f135acf17e93c2563b604e72335aef127dbea441329a9afe99652b49b19481ce14f77eab12b7a50045b55f64dad5935940435be981eb899ca
|
7
|
+
data.tar.gz: a71077426c955c8c0cf64743c2c3be9668c4a76ef6de4517c9b5e6f99e8bf8d109367e1f59bd586137e21e9f108b46fbc2568cffc73ebaa64cfbe8b9b74f2e9a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Sidekiq CloudWatch Metrics
|
2
2
|
|
3
|
-
[](https://travis-ci.org/sj26/sidekiq-cloudwatchmetrics)
|
4
|
-
|
5
3
|
Runs a thread inside your Sidekiq processes to report metrics to CloudWatch
|
6
4
|
useful for autoscaling and keeping an eye on your queues.
|
7
5
|
|
@@ -43,9 +41,14 @@ Sidekiq::CloudWatchMetrics.enable!(client: Aws::CloudWatch::Client.new)
|
|
43
41
|
The default namespace for metrics is "Sidekiq". You can configure this with the `namespace` option:
|
44
42
|
|
45
43
|
```ruby
|
46
|
-
Sidekiq::CloudWatchMetrics.enable!(
|
44
|
+
Sidekiq::CloudWatchMetrics.enable!(namespace: "Sidekiq-Staging")
|
47
45
|
```
|
48
46
|
|
47
|
+
Metrics are published every 60 seconds by default. You can adjust this with the `interval` option:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
Sidekiq::CloudWatchMetrics.enable!(interval: 30)
|
51
|
+
```
|
49
52
|
|
50
53
|
## Development
|
51
54
|
|
@@ -8,7 +8,7 @@ require "aws-sdk-cloudwatch"
|
|
8
8
|
module Sidekiq::CloudWatchMetrics
|
9
9
|
def self.enable!(**kwargs)
|
10
10
|
Sidekiq.configure_server do |config|
|
11
|
-
publisher = Publisher.new(**kwargs)
|
11
|
+
publisher = Publisher.new(config: config, **kwargs)
|
12
12
|
|
13
13
|
# Sidekiq enterprise has a globally unique leader thread, making it
|
14
14
|
# easier to publish the cluster-wide metrics from one place.
|
@@ -43,13 +43,24 @@ module Sidekiq::CloudWatchMetrics
|
|
43
43
|
include Sidekiq::Component
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
DEFAULT_INTERVAL = 60 # seconds
|
47
47
|
|
48
|
-
def
|
49
|
-
# Sidekiq
|
50
|
-
|
48
|
+
private def default_config
|
49
|
+
# Sidekiq::Config was introduced in sidekiq 7 and has a default
|
50
|
+
if Sidekiq.respond_to?(:default_configuration)
|
51
|
+
Sidekiq.default_configuration
|
52
|
+
else
|
53
|
+
# in older versions, it's just the `Sidekiq` module
|
54
|
+
Sidekiq
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize(config: default_config, client: Aws::CloudWatch::Client.new, namespace: "Sidekiq", process_metrics: true, additional_dimensions: {}, interval: DEFAULT_INTERVAL)
|
59
|
+
# Required by Sidekiq::Component (in sidekiq 6.5+)
|
51
60
|
@config = config
|
61
|
+
|
52
62
|
@client = client
|
63
|
+
@interval = interval
|
53
64
|
@namespace = namespace
|
54
65
|
@process_metrics = process_metrics
|
55
66
|
@additional_dimensions = additional_dimensions.map { |k, v| {name: k.to_s, value: v.to_s} }
|
@@ -69,15 +80,20 @@ module Sidekiq::CloudWatchMetrics
|
|
69
80
|
def run
|
70
81
|
logger.info { "Started Sidekiq CloudWatch Metrics Publisher" }
|
71
82
|
|
72
|
-
# Publish stats every
|
83
|
+
# Publish stats every @interval seconds, sleeping as required between runs
|
73
84
|
now = Time.now.to_f
|
74
85
|
tick = now
|
75
86
|
until @stop
|
76
87
|
logger.debug { "Publishing Sidekiq CloudWatch Metrics" }
|
77
|
-
|
88
|
+
begin
|
89
|
+
publish
|
90
|
+
rescue => e
|
91
|
+
logger.error("Error publishing Sidekiq CloudWatch Metrics: #{e}")
|
92
|
+
handle_exception(e)
|
93
|
+
end
|
78
94
|
|
79
95
|
now = Time.now.to_f
|
80
|
-
tick = [tick +
|
96
|
+
tick = [tick + @interval, now].max
|
81
97
|
sleep(tick - now) if tick > now
|
82
98
|
end
|
83
99
|
|
@@ -169,12 +185,22 @@ module Sidekiq::CloudWatchMetrics
|
|
169
185
|
end.each do |(tag, tag_processes)|
|
170
186
|
next if tag.nil?
|
171
187
|
|
188
|
+
tag_dimensions = [{name: "Tag", value: tag}]
|
189
|
+
|
190
|
+
metrics << {
|
191
|
+
metric_name: "Capacity",
|
192
|
+
dimensions: tag_dimensions,
|
193
|
+
timestamp: now,
|
194
|
+
value: calculate_capacity(tag_processes),
|
195
|
+
unit: "Count",
|
196
|
+
}
|
197
|
+
|
172
198
|
tag_utilization = calculate_utilization(tag_processes) * 100.0
|
173
199
|
|
174
200
|
unless tag_utilization.nan?
|
175
201
|
metrics << {
|
176
202
|
metric_name: "Utilization",
|
177
|
-
dimensions:
|
203
|
+
dimensions: tag_dimensions,
|
178
204
|
timestamp: now,
|
179
205
|
value: tag_utilization,
|
180
206
|
unit: "Percent",
|
@@ -189,7 +215,7 @@ module Sidekiq::CloudWatchMetrics
|
|
189
215
|
unless process_utilization.nan?
|
190
216
|
process_dimensions = [{name: "Hostname", value: process["hostname"]}]
|
191
217
|
|
192
|
-
if process["tag"]
|
218
|
+
if process["tag"] && !process["tag"].to_s.empty?
|
193
219
|
process_dimensions << {name: "Tag", value: process["tag"]}
|
194
220
|
end
|
195
221
|
|
@@ -264,8 +290,10 @@ module Sidekiq::CloudWatchMetrics
|
|
264
290
|
def stop
|
265
291
|
logger.debug { "Stopping Sidekiq CloudWatch Metrics Publisher" }
|
266
292
|
@stop = true
|
267
|
-
@thread
|
268
|
-
|
293
|
+
if @thread
|
294
|
+
@thread.wakeup
|
295
|
+
@thread.join
|
296
|
+
end
|
269
297
|
rescue ThreadError
|
270
298
|
# Don't raise if thread is already dead.
|
271
299
|
nil
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-cloudwatchmetrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Cochran
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDKDCCAhCgAwIBAgIBAzANBgkqhkiG9w0BAQsFADA6MQ0wCwYDVQQDDARzajI2
|
14
14
|
MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0y
|
15
|
-
|
15
|
+
NDA3MjIwNjA3MjdaFw0yNTA3MjIwNjA3MjdaMDoxDTALBgNVBAMMBHNqMjYxFDAS
|
16
16
|
BgoJkiaJk/IsZAEZFgRzajI2MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkq
|
17
17
|
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr60Eo/ttCk8GMTMFiPr3GoYMIMFvLak
|
18
18
|
xSmTk9YGCB6UiEePB4THSSA5w6IPyeaCF/nWkDp3/BAam0eZMWG1IzYQB23TqIM0
|
@@ -21,14 +21,14 @@ cert_chain:
|
|
21
21
|
4O/FL2ChjL2CPCpLZW55ShYyrzphWJwLOJe+FJ/ZBl6YXwrzQM9HKnt4titSNvyU
|
22
22
|
KzE3L63A3PZvExzLrN9u09kuWLLJfXB2sGOlw3n9t72rJiuBr3/OQQIDAQABozkw
|
23
23
|
NzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU99dfRjEKFyczTeIz
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
m3ZsDWrNC80wDQYJKoZIhvcNAQELBQADggEBAKcQ+MfpXXDmqboG36O8mXhJZJ8+
|
25
|
+
zlUqM1QnoEG8XpH/29py4GzSgs6Sb+v/Z1SEArRDq0r1bKZuWiWxqEDnmSE94+pe
|
26
|
+
A0Ct6Pv/paEhQCoPkGQNa74cH4tzkVHIA7WSwRL8wOz5vo++YBKH5H36nNqtLV7s
|
27
|
+
kNJYsbeOL/w2icQ4b0w4KYgcs4bd6yrYdgcgsRd2sCYb2XFHjczYqw4iEwuUenNM
|
28
|
+
G8WXc9zUMVewWkEjS9s++xFNb/7f4dFNXCoE3pgHjzctt7gYcJVacprsg925LYHO
|
29
|
+
WsbnbEow7BPlYOZm3rDIsEYpWqxN0lR8BakO2ToJ5RAHXahFu4K4eJtAsLk=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date:
|
31
|
+
date: 2025-03-24 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: sidekiq
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '5.0'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '9.0'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '5.0'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '9.0'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: aws-sdk-cloudwatch
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,7 +151,7 @@ homepage: https://github.com/sj26/sidekiq-cloudwatchmetrics
|
|
151
151
|
licenses:
|
152
152
|
- MIT
|
153
153
|
metadata: {}
|
154
|
-
post_install_message:
|
154
|
+
post_install_message:
|
155
155
|
rdoc_options: []
|
156
156
|
require_paths:
|
157
157
|
- lib
|
@@ -159,15 +159,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
159
|
requirements:
|
160
160
|
- - ">="
|
161
161
|
- !ruby/object:Gem::Version
|
162
|
-
version: '2.
|
162
|
+
version: '2.7'
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
164
|
requirements:
|
165
165
|
- - ">="
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
170
|
-
signing_key:
|
169
|
+
rubygems_version: 3.5.16
|
170
|
+
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Publish Sidekiq metrics to AWS CloudWatch
|
173
173
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|