sidekiq_prometheus 1.0.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/CHANGELOG.md +35 -0
- data/README.md +19 -3
- data/lib/sidekiq_prometheus.rb +23 -4
- data/lib/sidekiq_prometheus/job_metrics.rb +7 -2
- data/lib/sidekiq_prometheus/metrics.rb +3 -3
- data/lib/sidekiq_prometheus/periodic_metrics.rb +1 -1
- data/lib/sidekiq_prometheus/version.rb +1 -1
- data/sidekiq_prometheus.gemspec +5 -4
- metadata +28 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd485c3e82871eb0083e0f8c66b506d72624cdc48bcee1fa2e3c0d45eee9a8fa
|
4
|
+
data.tar.gz: a1e2fa1f170d6c2115c6de05bb9f029f4bc6c54f0fa208a683c9a074afc06c06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f52ccff4847c333ba9c50d9e5033214f0d739edd4eca461b1b9b5406c6d236505b0e3e7fcc04f7f26bc460debb16e0ada2f1834ffc49c73b24f8c9369fe21bff
|
7
|
+
data.tar.gz: 7e0e854ab573ead62b8ff19a1a8d736587e00250a4fd447a9bbc393d1765c7eab8083d6beb9f14ac7e766d88d28875088f8ee5a3bf2c77d34a1d00af5a573136
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,40 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
|
+
<a name="v1.3.0"></a>
|
4
|
+
## [v1.3.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.2.0...v1.3.0) (2021-03-26)
|
5
|
+
|
6
|
+
### Pull Requests
|
7
|
+
|
8
|
+
* Merge pull request [#22](https://github.com/fastly/sidekiq-prometheus/issues/22) from mirubiri/add-active-job-support
|
9
|
+
* Merge pull request [#20](https://github.com/fastly/sidekiq-prometheus/issues/20) from fastly/aw/move-to-main
|
10
|
+
|
11
|
+
<a name="v1.2.0"></a>
|
12
|
+
## [v1.2.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.1.0...v1.2.0) (2020-10-01)
|
13
|
+
|
14
|
+
### Feature
|
15
|
+
|
16
|
+
* allow the metrics host to be disabled with a configuration option
|
17
|
+
* use prometheus-client ~> 2.0
|
18
|
+
|
19
|
+
### Pull Requests
|
20
|
+
|
21
|
+
* Merge pull request [#17](https://github.com/fastly/sidekiq-prometheus/issues/17) from jetpks/add-option-to-disable-metrics-server
|
22
|
+
* Merge pull request [#15](https://github.com/fastly/sidekiq-prometheus/issues/15) from silicakes/master
|
23
|
+
|
24
|
+
<a name="v1.1.0"></a>
|
25
|
+
## [v1.1.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.0.1...v1.1.0) (2020-02-12)
|
26
|
+
|
27
|
+
### Feature
|
28
|
+
|
29
|
+
* allow for configuration of the metrics host (instead of always binding to 127.0.0.1)
|
30
|
+
* Use prometheus-client ~> 1.0.0
|
31
|
+
|
32
|
+
### Pull Requests
|
33
|
+
|
34
|
+
* Merge pull request [#13](https://github.com/fastly/sidekiq-prometheus/issues/13) from postmodern/metrics_host
|
35
|
+
* Merge pull request [#11](https://github.com/fastly/sidekiq-prometheus/issues/11) from rossjones/patch-1
|
36
|
+
* Merge pull request [#12](https://github.com/fastly/sidekiq-prometheus/issues/12) from fastly/hr
|
37
|
+
|
3
38
|
<a name="v1.0.0"></a>
|
4
39
|
## [v1.0.0](https://github.com/fastly/sidekiq-prometheus/compare/v0.9.1...v1.0.0) (2019-10-24)
|
5
40
|
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Sidekiq Prometheus
|
2
2
|
|
3
3
|
|
4
|
-
[![Status](https://travis-ci.org/fastly/sidekiq-prometheus.svg?branch=
|
4
|
+
[![Status](https://travis-ci.org/fastly/sidekiq-prometheus.svg?branch=main)](https://travis-ci.org/fastly/sidekiq-prometheus)
|
5
5
|
![Gem](https://img.shields.io/gem/v/sidekiq_prometheus.svg?color=blue)
|
6
6
|
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
|
7
7
|
|
@@ -81,6 +81,9 @@ end
|
|
81
81
|
* `global_metrics_enabled`: Boolean that determines whether to report global metrics from the PeriodicMetrics reporter. When `true` this will report on a number of stats from the Sidekiq API for the cluster. This requires Sidekiq::Enterprise as the reporter uses the leader election functionality to ensure that only one worker per cluster is reporting metrics.
|
82
82
|
* `periodic_metrics_enabled`: Boolean that determines whether to run the periodic metrics reporter. `PeriodicMetrics` runs a separate thread that reports on global metrics (if enabled) as well worker GC stats (if enabled). It reports metrics on the interval defined by `periodic_reporting_interval`. Defaults to `true`.
|
83
83
|
* `periodic_reporting_interval`: interval in seconds for reporting periodic metrics. Default: `30`
|
84
|
+
* `metrics_server_enabled`: Boolean that determines whether to run the rack server. Defaults to `true`
|
85
|
+
* `metrics_host`: Host on which the rack server will listen. Defaults to
|
86
|
+
`localhost`
|
84
87
|
* `metrics_port`: Port on which the rack server will listen. Defaults to `9359`
|
85
88
|
* `registry`: An instance of `Prometheus::Client::Registry`. If you have a registry with defined metrics you can use this option to pass in your registry.
|
86
89
|
|
@@ -92,6 +95,7 @@ SidekiqPrometheus.configure do |config|
|
|
92
95
|
config.global_metrics_enabled = true
|
93
96
|
config.periodic_metrics_enabled = true
|
94
97
|
config.periodic_reporting_interval = 20
|
98
|
+
config.metrics_server_enabled = true
|
95
99
|
config.metrics_port = 8675
|
96
100
|
end
|
97
101
|
```
|
@@ -243,10 +247,18 @@ See the [documentation of the Prometheus::Client library](https://github.com/pro
|
|
243
247
|
|
244
248
|
## Development
|
245
249
|
|
246
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
|
250
|
+
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.
|
247
251
|
|
248
252
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
249
253
|
|
254
|
+
## Contributors
|
255
|
+
|
256
|
+
* Lukas Eklund ([@leklund](https://github.com/leklund))
|
257
|
+
* NHM Tanveer Hossain Khan ([@we4tech](https://github.com/we4tech))
|
258
|
+
* [@Postmodern](https://github.com/postmodern)
|
259
|
+
* Ross Jones ([@rossjones](https://github.com/rossjones))
|
260
|
+
* Alejandro Arrufat ([@mirubiri](https://github.com/mirubiri))
|
261
|
+
|
250
262
|
## Contributing
|
251
263
|
|
252
264
|
Bug reports and pull requests are welcome on GitHub at https://github.com/fastly/sidekiq-prometheus. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
@@ -261,4 +273,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
261
273
|
|
262
274
|
## Code of Conduct
|
263
275
|
|
264
|
-
Everyone interacting in the SidekiqPrometheus project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fastly/sidekiq-prometheus/blob/
|
276
|
+
Everyone interacting in the SidekiqPrometheus project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fastly/sidekiq-prometheus/blob/main/CODE_OF_CONDUCT.md).
|
277
|
+
|
278
|
+
# Metadata
|
279
|
+
|
280
|
+
- Ignore
|
data/lib/sidekiq_prometheus.rb
CHANGED
@@ -6,6 +6,7 @@ require 'prometheus/client'
|
|
6
6
|
require 'prometheus/middleware/exporter'
|
7
7
|
require 'sidekiq'
|
8
8
|
require 'sidekiq/api'
|
9
|
+
require 'webrick'
|
9
10
|
|
10
11
|
begin
|
11
12
|
require 'sidekiq/ent'
|
@@ -47,6 +48,12 @@ module SidekiqPrometheus
|
|
47
48
|
# @return [Integer] Interval in seconds to record metrics. Default: 30
|
48
49
|
attr_accessor :periodic_reporting_interval
|
49
50
|
|
51
|
+
# @return [Boolean] Setting to control enabling/disabling the metrics server. Default: true
|
52
|
+
attr_accessor :metrics_server_enabled
|
53
|
+
|
54
|
+
# @return [String] Host on which the metrics server will listen. Default: localhost
|
55
|
+
attr_accessor :metrics_host
|
56
|
+
|
50
57
|
# @return [Integer] Port on which the metrics server will listen. Default: 9357
|
51
58
|
attr_accessor :metrics_port
|
52
59
|
|
@@ -66,6 +73,8 @@ module SidekiqPrometheus
|
|
66
73
|
self.periodic_metrics_enabled = true
|
67
74
|
self.global_metrics_enabled = true
|
68
75
|
self.periodic_reporting_interval = 30
|
76
|
+
self.metrics_server_enabled = true
|
77
|
+
self.metrics_host = 'localhost'
|
69
78
|
self.metrics_port = 9359
|
70
79
|
self.custom_labels = {}
|
71
80
|
self.custom_metrics = []
|
@@ -113,6 +122,13 @@ module SidekiqPrometheus
|
|
113
122
|
periodic_metrics_enabled
|
114
123
|
end
|
115
124
|
|
125
|
+
##
|
126
|
+
# Helper method for +metrics_server_enabled+ configuration setting
|
127
|
+
# @return [Boolean] defaults to true
|
128
|
+
def metrics_server_enabled?
|
129
|
+
metrics_server_enabled
|
130
|
+
end
|
131
|
+
|
116
132
|
##
|
117
133
|
# Get a metric from the registry
|
118
134
|
# @param metric [Symbol] name of metric to fetch
|
@@ -172,14 +188,17 @@ module SidekiqPrometheus
|
|
172
188
|
config.on(:shutdown) { SidekiqPrometheus::PeriodicMetrics.reporter.stop }
|
173
189
|
end
|
174
190
|
|
175
|
-
|
176
|
-
|
191
|
+
if metrics_server_enabled?
|
192
|
+
config.on(:startup) { SidekiqPrometheus.metrics_server }
|
193
|
+
config.on(:shutdown) { SidekiqPrometheus.metrics_server.kill }
|
194
|
+
end
|
177
195
|
end
|
178
196
|
end
|
179
197
|
|
180
198
|
##
|
181
199
|
# Start a new Prometheus exporter in a new thread.
|
182
|
-
# Will listen on SidekiqPrometheus.
|
200
|
+
# Will listen on SidekiqPrometheus.metrics_host and
|
201
|
+
# SidekiqPrometheus.metrics_port
|
183
202
|
def metrics_server
|
184
203
|
@_metrics_server ||= Thread.new do
|
185
204
|
Rack::Handler::WEBrick.run(
|
@@ -188,7 +207,7 @@ module SidekiqPrometheus
|
|
188
207
|
run ->(_) { [301, { 'Location' => '/metrics' }, []] }
|
189
208
|
},
|
190
209
|
Port: SidekiqPrometheus.metrics_port,
|
191
|
-
|
210
|
+
Host: SidekiqPrometheus.metrics_host,
|
192
211
|
)
|
193
212
|
end
|
194
213
|
end
|
@@ -1,10 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class SidekiqPrometheus::JobMetrics
|
4
|
-
def call(worker,
|
4
|
+
def call(worker, job, queue)
|
5
5
|
before = GC.stat(:total_allocated_objects) if SidekiqPrometheus.gc_metrics_enabled?
|
6
6
|
|
7
|
-
|
7
|
+
# If we're using a wrapper class, like ActiveJob, use the "wrapped"
|
8
|
+
# attribute to expose the underlying thing.
|
9
|
+
labels = {
|
10
|
+
class: job['wrapped'] || worker.class.to_s,
|
11
|
+
queue: queue,
|
12
|
+
}
|
8
13
|
|
9
14
|
begin
|
10
15
|
labels.merge!(custom_labels(worker))
|
@@ -107,7 +107,7 @@ module SidekiqPrometheus::Metrics
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def register_sidekiq_gc_metric
|
110
|
-
register
|
110
|
+
register(**SIDEKIQ_GC_METRIC)
|
111
111
|
end
|
112
112
|
|
113
113
|
def register_sidekiq_worker_gc_metrics
|
@@ -120,7 +120,7 @@ module SidekiqPrometheus::Metrics
|
|
120
120
|
|
121
121
|
def register_metrics(metrics)
|
122
122
|
metrics.each do |metric|
|
123
|
-
register(metric)
|
123
|
+
register(**metric)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -159,7 +159,7 @@ module SidekiqPrometheus::Metrics
|
|
159
159
|
|
160
160
|
options[:buckets] = buckets if buckets
|
161
161
|
|
162
|
-
registry.send(type, name.to_sym, options)
|
162
|
+
registry.send(type, name.to_sym, **options)
|
163
163
|
end
|
164
164
|
|
165
165
|
def unregister(name:)
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# one worker.
|
9
9
|
#
|
10
10
|
# @see https://github.com/mperham/sidekiq/wiki/Ent-Leader-Election
|
11
|
-
# @see https://github.com/mperham/sidekiq/blob/
|
11
|
+
# @see https://github.com/mperham/sidekiq/blob/main/lib/sidekiq/api.rb
|
12
12
|
|
13
13
|
class SidekiqPrometheus::PeriodicMetrics
|
14
14
|
# @return [Boolean] When +true+ will stop the reporting loop.
|
data/sidekiq_prometheus.gemspec
CHANGED
@@ -7,7 +7,7 @@ require 'sidekiq_prometheus/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'sidekiq_prometheus'
|
9
9
|
spec.version = SidekiqPrometheus::VERSION
|
10
|
-
spec.authors = ['Lukas Eklund']
|
10
|
+
spec.authors = ['Lukas Eklund', 'NHM Tanveer Hossain Khan']
|
11
11
|
spec.email = ['leklund@fastly.com']
|
12
12
|
|
13
13
|
spec.summary = 'Prometheus Instrumentation for Sidekiq'
|
@@ -23,11 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler'
|
25
25
|
spec.add_development_dependency 'pry'
|
26
|
-
spec.add_development_dependency 'rake', '~>
|
26
|
+
spec.add_development_dependency 'rake', '~> 12.3.3'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
28
|
spec.add_development_dependency 'rubocop', '~> 0.58.0'
|
29
29
|
|
30
|
-
spec.add_runtime_dependency 'prometheus-client', '~>
|
30
|
+
spec.add_runtime_dependency 'prometheus-client', '~> 2.0'
|
31
31
|
spec.add_runtime_dependency 'rack'
|
32
|
-
spec.add_runtime_dependency 'sidekiq', '
|
32
|
+
spec.add_runtime_dependency 'sidekiq', '> 5.1'
|
33
|
+
spec.add_runtime_dependency 'webrick'
|
33
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq_prometheus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Eklund
|
8
|
-
|
8
|
+
- NHM Tanveer Hossain Khan
|
9
|
+
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -44,14 +45,14 @@ dependencies:
|
|
44
45
|
requirements:
|
45
46
|
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
+
version: 12.3.3
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
53
|
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
+
version: 12.3.3
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
57
|
name: rspec
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +87,14 @@ dependencies:
|
|
86
87
|
requirements:
|
87
88
|
- - "~>"
|
88
89
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
+
version: '2.0'
|
90
91
|
type: :runtime
|
91
92
|
prerelease: false
|
92
93
|
version_requirements: !ruby/object:Gem::Requirement
|
93
94
|
requirements:
|
94
95
|
- - "~>"
|
95
96
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
+
version: '2.0'
|
97
98
|
- !ruby/object:Gem::Dependency
|
98
99
|
name: rack
|
99
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,17 +113,31 @@ dependencies:
|
|
112
113
|
name: sidekiq
|
113
114
|
requirement: !ruby/object:Gem::Requirement
|
114
115
|
requirements:
|
115
|
-
- - "
|
116
|
+
- - ">"
|
116
117
|
- !ruby/object:Gem::Version
|
117
118
|
version: '5.1'
|
118
119
|
type: :runtime
|
119
120
|
prerelease: false
|
120
121
|
version_requirements: !ruby/object:Gem::Requirement
|
121
122
|
requirements:
|
122
|
-
- - "
|
123
|
+
- - ">"
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '5.1'
|
125
|
-
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: webrick
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :runtime
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
description:
|
126
141
|
email:
|
127
142
|
- leklund@fastly.com
|
128
143
|
executables: []
|
@@ -152,7 +167,7 @@ homepage: https://github.com/fastly/sidekiq-prometheus
|
|
152
167
|
licenses:
|
153
168
|
- MIT
|
154
169
|
metadata: {}
|
155
|
-
post_install_message:
|
170
|
+
post_install_message:
|
156
171
|
rdoc_options: []
|
157
172
|
require_paths:
|
158
173
|
- lib
|
@@ -167,9 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
182
|
- !ruby/object:Gem::Version
|
168
183
|
version: '0'
|
169
184
|
requirements: []
|
170
|
-
|
171
|
-
|
172
|
-
signing_key:
|
185
|
+
rubygems_version: 3.0.6
|
186
|
+
signing_key:
|
173
187
|
specification_version: 4
|
174
188
|
summary: Prometheus Instrumentation for Sidekiq
|
175
189
|
test_files: []
|