sidekiq-cloudwatchmetrics 2.0.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +8 -1
- data/lib/sidekiq/cloudwatchmetrics.rb +34 -6
- data.tar.gz.sig +0 -0
- metadata +44 -23
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcda0d610239286e3289711209bcd52f55a9ab00f9e37d8d768531ec125e24aa
|
4
|
+
data.tar.gz: 3214895b04fdff713a7ed11c110b7c895e91307594f6ad73c80064a390a89323
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96944fbb1a4b5669280e6146533d5f9d19ed9e67fec5feff31d1cdcb79c545bd0fb7529701bb72fdf72cef2fadc7e6a728c53d5d81726760a7dc4bf781f26d82
|
7
|
+
data.tar.gz: 12fdaf02f031a14937ca4dfc03ab47e96f2e77f43b2b6b635784367326fcf2a94a0c6fbe284981dab7f1fd06cc4876ce8b197bcdd9cca3660c4dbcdb1caa50e5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -35,11 +35,18 @@ through environment variables that aws-sdk expects. You can also explicitly
|
|
35
35
|
supply an [aws-sdk CloudWatch Client instance][cwclient]:
|
36
36
|
|
37
37
|
```ruby
|
38
|
-
Sidekiq::CloudWatchMetrics.enable!(client:
|
38
|
+
Sidekiq::CloudWatchMetrics.enable!(client: Aws::CloudWatch::Client.new)
|
39
39
|
```
|
40
40
|
|
41
41
|
[cwclient]: https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/CloudWatch/Client.html
|
42
42
|
|
43
|
+
The default namespace for metrics is "Sidekiq". You can configure this with the `namespace` option:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
Sidekiq::CloudWatchMetrics.enable!(client: Aws::CloudWatch::Client.new, namespace: "Sidekiq-Staging")
|
47
|
+
```
|
48
|
+
|
49
|
+
|
43
50
|
## Development
|
44
51
|
|
45
52
|
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.
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require "sidekiq"
|
4
4
|
require "sidekiq/api"
|
5
|
-
require "sidekiq/util"
|
6
5
|
|
7
6
|
require "aws-sdk-cloudwatch"
|
8
7
|
|
@@ -11,8 +10,9 @@ module Sidekiq::CloudWatchMetrics
|
|
11
10
|
Sidekiq.configure_server do |config|
|
12
11
|
publisher = Publisher.new(**kwargs)
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
# Sidekiq enterprise has a globally unique leader thread, making it
|
14
|
+
# easier to publish the cluster-wide metrics from one place.
|
15
|
+
if defined?(Sidekiq::Enterprise)
|
16
16
|
config.on(:leader) do
|
17
17
|
publisher.start
|
18
18
|
end
|
@@ -34,12 +34,24 @@ module Sidekiq::CloudWatchMetrics
|
|
34
34
|
end
|
35
35
|
|
36
36
|
class Publisher
|
37
|
-
|
37
|
+
begin
|
38
|
+
require "sidekiq/util"
|
39
|
+
include Sidekiq::Util
|
40
|
+
rescue LoadError
|
41
|
+
# Sidekiq 6.5 refactored to use Sidekiq::Component
|
42
|
+
require "sidekiq/component"
|
43
|
+
include Sidekiq::Component
|
44
|
+
end
|
38
45
|
|
39
46
|
INTERVAL = 60 # seconds
|
40
47
|
|
41
|
-
def initialize(client: Aws::CloudWatch::Client.new)
|
48
|
+
def initialize(config: Sidekiq, client: Aws::CloudWatch::Client.new, namespace: "Sidekiq", additional_dimensions: {})
|
49
|
+
# Sidekiq 6.5+ requires @config, which defaults to the top-level
|
50
|
+
# `Sidekiq` module, but can be overridden when running multiple Sidekiqs.
|
51
|
+
@config = config
|
42
52
|
@client = client
|
53
|
+
@namespace = namespace
|
54
|
+
@additional_dimensions = additional_dimensions.map { |k, v| {name: k.to_s, value: v.to_s} }
|
43
55
|
end
|
44
56
|
|
45
57
|
def start
|
@@ -154,6 +166,14 @@ module Sidekiq::CloudWatchMetrics
|
|
154
166
|
value: process["busy"] / process["concurrency"].to_f * 100.0,
|
155
167
|
unit: "Percent",
|
156
168
|
}
|
169
|
+
|
170
|
+
metrics << {
|
171
|
+
metric_name: "Utilization",
|
172
|
+
dimensions: [{name: "Tag", value: process["tag"]}],
|
173
|
+
timestamp: now,
|
174
|
+
value: process["busy"] / process["concurrency"].to_f * 100.0,
|
175
|
+
unit: "Percent",
|
176
|
+
}
|
157
177
|
end
|
158
178
|
|
159
179
|
queues.each do |(queue_name, queue_size)|
|
@@ -176,10 +196,15 @@ module Sidekiq::CloudWatchMetrics
|
|
176
196
|
}
|
177
197
|
end
|
178
198
|
|
199
|
+
unless @additional_dimensions.empty?
|
200
|
+
metrics = metrics.each do |metric|
|
201
|
+
metric[:dimensions] = (metric[:dimensions] || []) + @additional_dimensions
|
202
|
+
end
|
203
|
+
end
|
179
204
|
# We can only put 20 metrics at a time
|
180
205
|
metrics.each_slice(20) do |some_metrics|
|
181
206
|
@client.put_metric_data(
|
182
|
-
namespace:
|
207
|
+
namespace: @namespace,
|
183
208
|
metric_data: some_metrics,
|
184
209
|
)
|
185
210
|
end
|
@@ -209,6 +234,9 @@ module Sidekiq::CloudWatchMetrics
|
|
209
234
|
@stop = true
|
210
235
|
@thread.wakeup
|
211
236
|
@thread.join
|
237
|
+
rescue ThreadError
|
238
|
+
# Don't raise if thread is already dead.
|
239
|
+
nil
|
212
240
|
end
|
213
241
|
end
|
214
242
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-cloudwatchmetrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Cochran
|
@@ -10,40 +10,47 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MIIDXDCCAkSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA6MQ0wCwYDVQQDDARzajI2
|
14
|
+
MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0y
|
15
|
+
MjA3MDQwMDQwNDZaFw0yMzA3MDQwMDQwNDZaMDoxDTALBgNVBAMMBHNqMjYxFDAS
|
16
16
|
BgoJkiaJk/IsZAEZFgRzajI2MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkq
|
17
17
|
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr60Eo/ttCk8GMTMFiPr3GoYMIMFvLak
|
18
18
|
xSmTk9YGCB6UiEePB4THSSA5w6IPyeaCF/nWkDp3/BAam0eZMWG1IzYQB23TqIM0
|
19
19
|
1xzcNRvFsn0aQoQ00k+sj+G83j3T5OOV5OZIlu8xAChMkQmiPd1NXc6uFv+Iacz7
|
20
20
|
kj+CMsI9YUFdNoU09QY0b+u+Rb6wDYdpyvN60YC30h0h1MeYbvYZJx/iZK4XY5zu
|
21
21
|
4O/FL2ChjL2CPCpLZW55ShYyrzphWJwLOJe+FJ/ZBl6YXwrzQM9HKnt4titSNvyU
|
22
|
-
KzE3L63A3PZvExzLrN9u09kuWLLJfXB2sGOlw3n9t72rJiuBr3/
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
KzE3L63A3PZvExzLrN9u09kuWLLJfXB2sGOlw3n9t72rJiuBr3/OQQIDAQABo20w
|
23
|
+
azAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU99dfRjEKFyczTeIz
|
24
|
+
m3ZsDWrNC80wGAYDVR0RBBEwD4ENc2oyNkBzajI2LmNvbTAYBgNVHRIEETAPgQ1z
|
25
|
+
ajI2QHNqMjYuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCsa7k3TABBcyXotr3yCq6f
|
26
|
+
xsgbMG9FR71c4wRgVNQi9O3jN64fQBbxo//BQlHfPCjs1CeU4es9xdQFfhqXAPXG
|
27
|
+
P7mK3+qd5jObjh6l3/rDKrTXNS+P+YO/1frlZ6xPjCA8XgGc4y0rhAjZnVBDV6t1
|
28
|
+
kmdtEmue1s1OxaMakr78XRZDxEuAeLM5fg8MYnlOFygEcAH6lZkTjXavY7s9MXRB
|
29
|
+
AAMioxgB6J5QhXQ42OSWIzwHZIbSv3DV9Lf5sde50HIW5f9u5jn29TUGDhSWYKkh
|
30
|
+
LDvy9dfwMMOdIZi75Q8SBBib84AuwhMHIlUv9FcHhh3dXsDDYkrVrpUAwCsG6yCm
|
30
31
|
-----END CERTIFICATE-----
|
31
|
-
date:
|
32
|
+
date: 2022-08-15 00:00:00.000000000 Z
|
32
33
|
dependencies:
|
33
34
|
- !ruby/object:Gem::Dependency
|
34
35
|
name: sidekiq
|
35
36
|
requirement: !ruby/object:Gem::Requirement
|
36
37
|
requirements:
|
37
|
-
- - "
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- - "<"
|
38
42
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
43
|
+
version: '7.0'
|
40
44
|
type: :runtime
|
41
45
|
prerelease: false
|
42
46
|
version_requirements: !ruby/object:Gem::Requirement
|
43
47
|
requirements:
|
44
|
-
- - "
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '5.0'
|
51
|
+
- - "<"
|
45
52
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
53
|
+
version: '7.0'
|
47
54
|
- !ruby/object:Gem::Dependency
|
48
55
|
name: aws-sdk-cloudwatch
|
49
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,28 +71,28 @@ dependencies:
|
|
64
71
|
requirements:
|
65
72
|
- - "~>"
|
66
73
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
74
|
+
version: '2.2'
|
68
75
|
type: :development
|
69
76
|
prerelease: false
|
70
77
|
version_requirements: !ruby/object:Gem::Requirement
|
71
78
|
requirements:
|
72
79
|
- - "~>"
|
73
80
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
81
|
+
version: '2.2'
|
75
82
|
- !ruby/object:Gem::Dependency
|
76
83
|
name: rake
|
77
84
|
requirement: !ruby/object:Gem::Requirement
|
78
85
|
requirements:
|
79
86
|
- - "~>"
|
80
87
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
88
|
+
version: '12.3'
|
82
89
|
type: :development
|
83
90
|
prerelease: false
|
84
91
|
version_requirements: !ruby/object:Gem::Requirement
|
85
92
|
requirements:
|
86
93
|
- - "~>"
|
87
94
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
95
|
+
version: '12.3'
|
89
96
|
- !ruby/object:Gem::Dependency
|
90
97
|
name: rspec
|
91
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +121,20 @@ dependencies:
|
|
114
121
|
- - "~>"
|
115
122
|
- !ruby/object:Gem::Version
|
116
123
|
version: '0.9'
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: rexml
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '3.2'
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '3.2'
|
117
138
|
description: |
|
118
139
|
Runs a thread inside your Sidekiq processes to report metrics to CloudWatch
|
119
140
|
useful for autoscaling and keeping an eye on your queues.
|
@@ -137,7 +158,7 @@ require_paths:
|
|
137
158
|
- lib
|
138
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
139
160
|
requirements:
|
140
|
-
- - "
|
161
|
+
- - ">="
|
141
162
|
- !ruby/object:Gem::Version
|
142
163
|
version: '2.4'
|
143
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -146,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
167
|
- !ruby/object:Gem::Version
|
147
168
|
version: '0'
|
148
169
|
requirements: []
|
149
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.1.6
|
150
171
|
signing_key:
|
151
172
|
specification_version: 4
|
152
173
|
summary: Publish Sidekiq metrics to AWS CloudWatch
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
�����舤-�pq*
|
2
|
+
�D����J�����@}��%��b`O�Tpg�"���v�W�h�m�g�X���3�6VεH�%��As�"���}�|kؐ˦�>����1����x��+��JL�:���J���6��/��R�<⩋No�V.�OF2u�!�쥅}/e)��1���7��t�����U;�-8uti����@�劋nY��/����\��.W`om���1`o�r�����q�G,T�ŋ
|