sidekiq_prometheus 1.1.0 → 1.5.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 +52 -0
- data/README.md +8 -3
- data/lib/sidekiq_prometheus.rb +16 -2
- data/lib/sidekiq_prometheus/job_metrics.rb +9 -3
- data/lib/sidekiq_prometheus/metrics.rb +4 -4
- data/lib/sidekiq_prometheus/periodic_metrics.rb +1 -1
- data/lib/sidekiq_prometheus/version.rb +1 -1
- data/sidekiq_prometheus.gemspec +3 -2
- metadata +25 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49989dd6e8b4c7c651f70d69e674630900cf5eb3150c4be85df6becb83fc1d18
|
4
|
+
data.tar.gz: c42b2eac238eaa7c435628962872c750c08b1430a8166219de0343c4fe987fa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23702691b261c1f0ea0984cccca1267cb5ad3be7a3ebd0ea4c7591d12bb9403e5104cedc372b023f440e080a71ff5c432022f35527ff1e898dba5d07a36ab056
|
7
|
+
data.tar.gz: 84197b360bbe8c54da5c1e83911643a274a132164bf699d2f8672fbc908e93216918dc405f829f919f9a27fbbaf25d4bed26ff132428f29d14599a5eed1f1d73
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,57 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
|
+
|
4
|
+
<a name="v1.5.0"></a>
|
5
|
+
## [v1.5.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.4.0...v1.5.0) (2021-08-02)
|
6
|
+
|
7
|
+
### Pull Requests
|
8
|
+
|
9
|
+
* Merge pull request [#23](https://github.com/fastly/sidekiq-prometheus/issues/23) from fastly/rainy/add-error-class-label
|
10
|
+
|
11
|
+
|
12
|
+
<a name="v1.4.0"></a>
|
13
|
+
## [v1.4.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.3.0...v1.4.0) (2021-03-30)
|
14
|
+
|
15
|
+
### Pull Requests
|
16
|
+
|
17
|
+
* Merge pull request [#21](https://github.com/fastly/sidekiq-prometheus/issues/21) from Kevinrob/patch-1
|
18
|
+
|
19
|
+
|
20
|
+
<a name="v1.3.0"></a>
|
21
|
+
## [v1.3.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.2.0...v1.3.0) (2021-03-26)
|
22
|
+
|
23
|
+
### Pull Requests
|
24
|
+
|
25
|
+
* Merge pull request [#22](https://github.com/fastly/sidekiq-prometheus/issues/22) from mirubiri/add-active-job-support
|
26
|
+
* Merge pull request [#20](https://github.com/fastly/sidekiq-prometheus/issues/20) from fastly/aw/move-to-main
|
27
|
+
|
28
|
+
<a name="v1.2.0"></a>
|
29
|
+
## [v1.2.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.1.0...v1.2.0) (2020-10-01)
|
30
|
+
|
31
|
+
### Feature
|
32
|
+
|
33
|
+
* allow the metrics host to be disabled with a configuration option
|
34
|
+
* use prometheus-client ~> 2.0
|
35
|
+
|
36
|
+
### Pull Requests
|
37
|
+
|
38
|
+
* Merge pull request [#17](https://github.com/fastly/sidekiq-prometheus/issues/17) from jetpks/add-option-to-disable-metrics-server
|
39
|
+
* Merge pull request [#15](https://github.com/fastly/sidekiq-prometheus/issues/15) from silicakes/master
|
40
|
+
|
41
|
+
<a name="v1.1.0"></a>
|
42
|
+
## [v1.1.0](https://github.com/fastly/sidekiq-prometheus/compare/v1.0.1...v1.1.0) (2020-02-12)
|
43
|
+
|
44
|
+
### Feature
|
45
|
+
|
46
|
+
* allow for configuration of the metrics host (instead of always binding to 127.0.0.1)
|
47
|
+
* Use prometheus-client ~> 1.0.0
|
48
|
+
|
49
|
+
### Pull Requests
|
50
|
+
|
51
|
+
* Merge pull request [#13](https://github.com/fastly/sidekiq-prometheus/issues/13) from postmodern/metrics_host
|
52
|
+
* Merge pull request [#11](https://github.com/fastly/sidekiq-prometheus/issues/11) from rossjones/patch-1
|
53
|
+
* Merge pull request [#12](https://github.com/fastly/sidekiq-prometheus/issues/12) from fastly/hr
|
54
|
+
|
3
55
|
<a name="v1.0.0"></a>
|
4
56
|
## [v1.0.0](https://github.com/fastly/sidekiq-prometheus/compare/v0.9.1...v1.0.0) (2019-10-24)
|
5
57
|
|
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,7 @@ 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`
|
84
85
|
* `metrics_host`: Host on which the rack server will listen. Defaults to
|
85
86
|
`localhost`
|
86
87
|
* `metrics_port`: Port on which the rack server will listen. Defaults to `9359`
|
@@ -94,6 +95,7 @@ SidekiqPrometheus.configure do |config|
|
|
94
95
|
config.global_metrics_enabled = true
|
95
96
|
config.periodic_metrics_enabled = true
|
96
97
|
config.periodic_reporting_interval = 20
|
98
|
+
config.metrics_server_enabled = true
|
97
99
|
config.metrics_port = 8675
|
98
100
|
end
|
99
101
|
```
|
@@ -245,7 +247,7 @@ See the [documentation of the Prometheus::Client library](https://github.com/pro
|
|
245
247
|
|
246
248
|
## Development
|
247
249
|
|
248
|
-
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.
|
249
251
|
|
250
252
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
251
253
|
|
@@ -253,6 +255,9 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
253
255
|
|
254
256
|
* Lukas Eklund ([@leklund](https://github.com/leklund))
|
255
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))
|
256
261
|
|
257
262
|
## Contributing
|
258
263
|
|
@@ -268,7 +273,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
268
273
|
|
269
274
|
## Code of Conduct
|
270
275
|
|
271
|
-
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).
|
272
277
|
|
273
278
|
# Metadata
|
274
279
|
|
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,9 @@ 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
|
+
|
50
54
|
# @return [String] Host on which the metrics server will listen. Default: localhost
|
51
55
|
attr_accessor :metrics_host
|
52
56
|
|
@@ -69,6 +73,7 @@ module SidekiqPrometheus
|
|
69
73
|
self.periodic_metrics_enabled = true
|
70
74
|
self.global_metrics_enabled = true
|
71
75
|
self.periodic_reporting_interval = 30
|
76
|
+
self.metrics_server_enabled = true
|
72
77
|
self.metrics_host = 'localhost'
|
73
78
|
self.metrics_port = 9359
|
74
79
|
self.custom_labels = {}
|
@@ -117,6 +122,13 @@ module SidekiqPrometheus
|
|
117
122
|
periodic_metrics_enabled
|
118
123
|
end
|
119
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
|
+
|
120
132
|
##
|
121
133
|
# Get a metric from the registry
|
122
134
|
# @param metric [Symbol] name of metric to fetch
|
@@ -176,8 +188,10 @@ module SidekiqPrometheus
|
|
176
188
|
config.on(:shutdown) { SidekiqPrometheus::PeriodicMetrics.reporter.stop }
|
177
189
|
end
|
178
190
|
|
179
|
-
|
180
|
-
|
191
|
+
if metrics_server_enabled?
|
192
|
+
config.on(:startup) { SidekiqPrometheus.metrics_server }
|
193
|
+
config.on(:shutdown) { SidekiqPrometheus.metrics_server.kill }
|
194
|
+
end
|
181
195
|
end
|
182
196
|
end
|
183
197
|
|
@@ -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))
|
@@ -25,7 +30,8 @@ class SidekiqPrometheus::JobMetrics
|
|
25
30
|
|
26
31
|
result
|
27
32
|
rescue StandardError => e
|
28
|
-
|
33
|
+
err_label = { :error_class => e.class.to_s }
|
34
|
+
registry[:sidekiq_job_failed].increment(labels: err_label.merge(labels))
|
29
35
|
raise e
|
30
36
|
ensure
|
31
37
|
registry[:sidekiq_job_count].increment(labels: labels)
|
@@ -64,7 +64,7 @@ module SidekiqPrometheus::Metrics
|
|
64
64
|
{ name: :sidekiq_job_failed,
|
65
65
|
type: :counter,
|
66
66
|
docstring: 'Count of failed Sidekiq jobs',
|
67
|
-
labels: JOB_LABELS, },
|
67
|
+
labels: JOB_LABELS + [:error_class], },
|
68
68
|
{ name: :sidekiq_job_success,
|
69
69
|
type: :counter,
|
70
70
|
docstring: 'Count of successful Sidekiq jobs',
|
@@ -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
@@ -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
32
|
spec.add_runtime_dependency 'sidekiq', '> 5.1'
|
33
|
+
spec.add_runtime_dependency 'webrick'
|
33
34
|
end
|
metadata
CHANGED
@@ -1,15 +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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Eklund
|
8
8
|
- NHM Tanveer Hossain Khan
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 12.3.3
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 12.3.3
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,14 +87,14 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
90
|
+
version: '2.0'
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
97
|
+
version: '2.0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: rack
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,21 @@ dependencies:
|
|
123
123
|
- - ">"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '5.1'
|
126
|
-
|
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:
|
127
141
|
email:
|
128
142
|
- leklund@fastly.com
|
129
143
|
executables: []
|
@@ -153,7 +167,7 @@ homepage: https://github.com/fastly/sidekiq-prometheus
|
|
153
167
|
licenses:
|
154
168
|
- MIT
|
155
169
|
metadata: {}
|
156
|
-
post_install_message:
|
170
|
+
post_install_message:
|
157
171
|
rdoc_options: []
|
158
172
|
require_paths:
|
159
173
|
- lib
|
@@ -168,9 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
182
|
- !ruby/object:Gem::Version
|
169
183
|
version: '0'
|
170
184
|
requirements: []
|
171
|
-
|
172
|
-
|
173
|
-
signing_key:
|
185
|
+
rubygems_version: 3.1.6
|
186
|
+
signing_key:
|
174
187
|
specification_version: 4
|
175
188
|
summary: Prometheus Instrumentation for Sidekiq
|
176
189
|
test_files: []
|