prometheus_exporter 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +35 -31
- data/CHANGELOG +33 -27
- data/README.md +43 -23
- data/bin/prometheus_exporter +2 -2
- data/lib/prometheus_exporter/instrumentation/sidekiq.rb +1 -1
- data/lib/prometheus_exporter/instrumentation/sidekiq_stats.rb +43 -0
- data/lib/prometheus_exporter/instrumentation.rb +1 -0
- data/lib/prometheus_exporter/middleware.rb +5 -0
- data/lib/prometheus_exporter/server/collector.rb +1 -0
- data/lib/prometheus_exporter/server/sidekiq_process_collector.rb +1 -1
- data/lib/prometheus_exporter/server/sidekiq_stats_collector.rb +46 -0
- data/lib/prometheus_exporter/server.rb +1 -0
- data/lib/prometheus_exporter/version.rb +1 -1
- data/prometheus_exporter.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a885aa655d0bd9d939bef77ec5d7c37027d19882a96b184d0351c49593393b9
|
4
|
+
data.tar.gz: bca2080108cb8169d5589ee481fc40b0edb39e890a8a0fba6ec301a987c35396
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b21fe8ad31aec32b877ab50146759715c41968dd1edc510af7b986436983217fd7eb0c468faf2ceca7897ae855a36a88f3b6aef1e0dcf776846051e4cd35b822
|
7
|
+
data.tar.gz: 5a0a61bd914c269385bb6b46df97b2eca5e6fe4573092f10dfed7d92a4f052b62761faa53902bfdf93e2286dc96a13bc804dd56e820dec99c95a00550026b741
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
name:
|
1
|
+
name: CI
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
5
|
+
branches:
|
6
|
+
- main
|
5
7
|
pull_request:
|
6
8
|
schedule:
|
7
9
|
- cron: '0 0 * * 0' # weekly
|
@@ -9,41 +11,43 @@ on:
|
|
9
11
|
jobs:
|
10
12
|
build:
|
11
13
|
runs-on: ubuntu-latest
|
12
|
-
name: Ruby ${{ matrix.ruby }}
|
14
|
+
name: Ruby ${{ matrix.ruby }} AR ${{ matrix.activerecord }}
|
15
|
+
timeout-minutes: 10
|
16
|
+
|
17
|
+
env:
|
18
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/ar_${{ matrix.activerecord }}.gemfile
|
19
|
+
|
13
20
|
strategy:
|
21
|
+
fail-fast: false
|
14
22
|
matrix:
|
15
|
-
ruby: [
|
23
|
+
ruby: [2.6, 2.7, 3.0]
|
24
|
+
activerecord: [60, 61]
|
25
|
+
|
16
26
|
steps:
|
17
|
-
- uses: actions/checkout@
|
18
|
-
|
19
|
-
|
20
|
-
- uses: actions/setup-ruby@v1
|
27
|
+
- uses: actions/checkout@v2
|
28
|
+
|
29
|
+
- uses: ruby/setup-ruby@v1
|
21
30
|
with:
|
22
31
|
ruby-version: ${{ matrix.ruby }}
|
23
|
-
|
24
|
-
|
25
|
-
path: vendor/bundle
|
26
|
-
key: ${{ runner.os }}-${{ matrix.ruby }}-gems-v2-${{ hashFiles('**/Gemfile.lock') }}
|
27
|
-
restore-keys: |
|
28
|
-
${{ runner.os }}-${{ matrix.ruby }}-gems-v2-
|
29
|
-
|
30
|
-
- name: Downgrade rubygems
|
31
|
-
run: |
|
32
|
-
# for Ruby <= 2.6 , details https://github.com/rubygems/rubygems/issues/3284
|
33
|
-
gem update --system 3.0.8
|
34
|
-
if: ${{ matrix.ruby == '2.6' || matrix.ruby == '2.7' }}
|
35
|
-
- name: Upgrade rubygems
|
36
|
-
run: |
|
37
|
-
gem update --system
|
38
|
-
- name: Setup gems
|
39
|
-
run: |
|
40
|
-
gem install bundler
|
41
|
-
bundle config path vendor/bundle
|
42
|
-
bundle install --jobs 4
|
43
|
-
bundle exec appraisal install
|
32
|
+
bundler-cache: true
|
33
|
+
|
44
34
|
- name: Rubocop
|
45
35
|
run: bundle exec rubocop
|
46
|
-
|
47
|
-
run: bundle exec appraisal bundle
|
36
|
+
|
48
37
|
- name: Run tests
|
49
|
-
run: bundle exec
|
38
|
+
run: bundle exec rake
|
39
|
+
|
40
|
+
publish:
|
41
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
42
|
+
needs: build
|
43
|
+
runs-on: ubuntu-latest
|
44
|
+
|
45
|
+
steps:
|
46
|
+
- uses: actions/checkout@v2
|
47
|
+
|
48
|
+
- name: Release gem
|
49
|
+
uses: discourse/publish-rubygems-action@v2
|
50
|
+
env:
|
51
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
52
|
+
GIT_EMAIL: team@discourse.org
|
53
|
+
GIT_NAME: discoursebot
|
data/CHANGELOG
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1 - 2021-12-22
|
2
|
+
|
3
|
+
- FEATURE: add labels to preflight requests
|
4
|
+
- FEATURE: SidekiqStats metrics
|
5
|
+
- FIX: mintor refactors to Sidekiq metrics
|
6
|
+
|
7
|
+
1.0.0 - 2021-11-23
|
2
8
|
|
3
9
|
- BREAKING: rename metrics to match prometheus official naming conventions (See https://prometheus.io/docs/practices/naming/#metric-names)
|
4
10
|
- FEATURE: Sidekiq process metrics
|
@@ -6,11 +12,11 @@
|
|
6
12
|
- FIX: logger improved for web server
|
7
13
|
- FIX: Remove job labels from DelayedJob queues
|
8
14
|
|
9
|
-
0.8.1 -
|
15
|
+
0.8.1 - 2021-08-04
|
10
16
|
|
11
17
|
- FEATURE: swap from hardcoded STDERR to logger pattern (see README for details)
|
12
18
|
|
13
|
-
0.8.0 -
|
19
|
+
0.8.0 - 2021-07-05
|
14
20
|
|
15
21
|
- FIX: handle ThreadError more gracefully in cases where process shuts down
|
16
22
|
- FEATURE: add job_name and queue_name labels to delayed job metrics
|
@@ -22,7 +28,7 @@
|
|
22
28
|
- FEATURE: Improve Active Record instrumentation
|
23
29
|
- FEATURE: Support HTTP_X_AMZN_TRACE_ID when supplied
|
24
30
|
|
25
|
-
0.7.0 -
|
31
|
+
0.7.0 - 2020-12-29
|
26
32
|
|
27
33
|
- Dev: Removed support from EOL rubies, only 2.5, 2.6, 2.7 and 3.0 are supported now.
|
28
34
|
- Dev: Better support for Ruby 3.0, explicitly depending on webrick
|
@@ -30,111 +36,111 @@
|
|
30
36
|
- FEATURE: clean pattern for overriding middleware labels was introduced (in README)
|
31
37
|
- Fix: Better support for forking
|
32
38
|
|
33
|
-
0.6.0 -
|
39
|
+
0.6.0 - 2020-11-17
|
34
40
|
|
35
41
|
- FEATURE: add support for basic-auth in the prometheus_exporter web server
|
36
42
|
|
37
|
-
0.5.3 -
|
43
|
+
0.5.3 - 2020-07-29
|
38
44
|
|
39
45
|
- FEATURE: added #remove to all metric types so users can remove specific labels if needed
|
40
46
|
|
41
|
-
0.5.2 -
|
47
|
+
0.5.2 - 2020-07-01
|
42
48
|
|
43
49
|
- FEATURE: expanded instrumentation for sidekiq
|
44
50
|
- FEATURE: configurable default labels
|
45
51
|
|
46
|
-
0.5.1 -
|
52
|
+
0.5.1 - 2020-02-25
|
47
53
|
|
48
54
|
- FEATURE: Allow configuring the default client's host and port via environment variables
|
49
55
|
|
50
|
-
0.5.0 -
|
56
|
+
0.5.0 - 2020-02-14
|
51
57
|
|
52
58
|
- Breaking change: listen only to localhost by default to prevent unintended insecure configuration
|
53
59
|
- FIX: Avoid calling `hostname` aggressively, instead cache it on the exporter instance
|
54
60
|
|
55
|
-
0.4.17 -
|
61
|
+
0.4.17 - 2020-01-13
|
56
62
|
|
57
63
|
- FEATURE: add support for `to_h` on all metrics which can be used to query existing key/values
|
58
64
|
|
59
|
-
0.4.16 -
|
65
|
+
0.4.16 - 2019-11-04
|
60
66
|
|
61
67
|
- FEATURE: Support #reset! on all metric types to reset a metric to default
|
62
68
|
|
63
|
-
0.4.15 -
|
69
|
+
0.4.15 - 2019-11-04
|
64
70
|
|
65
71
|
- FEATURE: Improve delayed job collector, add pending counts
|
66
72
|
- FEATURE: New ActiveRecord collector (documented in readme)
|
67
73
|
- FEATURE: Allow passing in histogram and summary options
|
68
74
|
- FEATURE: Allow custom labels for unicorn collector
|
69
75
|
|
70
|
-
0.4.14 -
|
76
|
+
0.4.14 - 2019-09-10
|
71
77
|
|
72
78
|
- FEATURE: allow finding metrics by name RemoteMetric #find_registered_metric
|
73
79
|
- FIX: guard socket closing
|
74
80
|
|
75
|
-
0.4.13 -
|
81
|
+
0.4.13 - 2019-07-09
|
76
82
|
|
77
83
|
- Fix: Memory leak in unicorn and puma collectors
|
78
84
|
|
79
|
-
0.4.12 -
|
85
|
+
0.4.12 - 2019-05-30
|
80
86
|
|
81
87
|
- Fix: unicorn collector reporting incorrect number of unicorn workers
|
82
88
|
|
83
|
-
0.4.11 -
|
89
|
+
0.4.11 - 2019-05-15
|
84
90
|
|
85
91
|
- Fix: Handle stopping nil worker_threads in Client
|
86
92
|
- Dev: add frozen string literals
|
87
93
|
|
88
|
-
0.4.10 -
|
94
|
+
0.4.10 - 2019-04-29
|
89
95
|
|
90
96
|
- Fix: Custom label support for puma collector
|
91
97
|
- Fix: Raindrops socket collector not working correctly
|
92
98
|
|
93
|
-
0.4.9 -
|
99
|
+
0.4.9 - 2019-04-11
|
94
100
|
|
95
101
|
- Fix: Gem was not working correctly in Ruby 2.4 and below due to a syntax error
|
96
102
|
|
97
|
-
0.4.8 -
|
103
|
+
0.4.8 - 2019-04-10
|
98
104
|
|
99
105
|
- Feature: added helpers for instrumenting unicorn using raindrops
|
100
106
|
|
101
|
-
0.4.7 -
|
107
|
+
0.4.7 - 2019-04-08
|
102
108
|
|
103
109
|
- Fix: collector was not escaping " \ and \n correctly. This could lead
|
104
110
|
to a corrupt payload in some cases.
|
105
111
|
|
106
|
-
0.4.6 -
|
112
|
+
0.4.6 - 2019-04-02
|
107
113
|
|
108
114
|
- Feature: Allow resetting a counter
|
109
115
|
- Feature: Add sidekiq metrics: restarted, dead jobs counters
|
110
116
|
- Fix: Client shutting down before sending metrics to collector
|
111
117
|
|
112
|
-
0.4.5 -
|
118
|
+
0.4.5 - 2019-02-14
|
113
119
|
|
114
120
|
- Feature: Allow process collector to ship custom labels for all process metrics
|
115
121
|
- Fix: Always scope process metrics on hostname in collector
|
116
122
|
|
117
|
-
0.4.4 -
|
123
|
+
0.4.4 - 2019-02-13
|
118
124
|
|
119
125
|
- Feature: add support for local metric collection without using HTTP
|
120
126
|
|
121
|
-
0.4.3 -
|
127
|
+
0.4.3 - 2019-02-11
|
122
128
|
|
123
129
|
- Feature: Add alias for Gauge #observe called #set, this makes it a bit easier to migrate from prom
|
124
130
|
- Feature: Add increment and decrement to Counter
|
125
131
|
|
126
|
-
0.4.2 -
|
132
|
+
0.4.2 - 2018-11-30
|
127
133
|
|
128
134
|
- Fix/Feature: setting a Gauge to nil will remove Gauge (setting to non numeric will raise)
|
129
135
|
|
130
|
-
0.4.0 -
|
136
|
+
0.4.0 - 2018-10-23
|
131
137
|
|
132
138
|
- Feature: histogram support
|
133
139
|
- Feature: custom quantile support for summary
|
134
140
|
- Feature: Puma metrics
|
135
141
|
- Fix: delayed job metrics
|
136
142
|
|
137
|
-
0.3.4 -
|
143
|
+
0.3.4 - 2018-10-02
|
138
144
|
|
139
145
|
- Fix: custom collector via CLI was not working correctly
|
140
146
|
|
data/README.md
CHANGED
@@ -367,43 +367,49 @@ Metrics collected by Process instrumentation include labels `type` (as given wit
|
|
367
367
|
|
368
368
|
#### Sidekiq metrics
|
369
369
|
|
370
|
-
|
371
|
-
|
372
|
-
```ruby
|
373
|
-
Sidekiq.configure_server do |config|
|
374
|
-
config.server_middleware do |chain|
|
375
|
-
require 'prometheus_exporter/instrumentation'
|
376
|
-
chain.add PrometheusExporter::Instrumentation::Sidekiq
|
377
|
-
end
|
378
|
-
config.death_handlers << PrometheusExporter::Instrumentation::Sidekiq.death_handler
|
379
|
-
end
|
380
|
-
```
|
381
|
-
|
382
|
-
To monitor Queue size and latency:
|
370
|
+
There are different kinds of Sidekiq metrics that can be collected. A recommended setup looks like this:
|
383
371
|
|
384
372
|
```ruby
|
385
373
|
Sidekiq.configure_server do |config|
|
374
|
+
require 'prometheus_exporter/instrumentation'
|
375
|
+
config.server_middleware do |chain|
|
376
|
+
chain.add PrometheusExporter::Instrumentation::Sidekiq
|
377
|
+
end
|
378
|
+
config.death_handlers << PrometheusExporter::Instrumentation::Sidekiq.death_handler
|
386
379
|
config.on :startup do
|
387
|
-
|
380
|
+
PrometheusExporter::Instrumentation::Process.start type: 'sidekiq'
|
381
|
+
PrometheusExporter::Instrumentation::SidekiqProcess.start
|
388
382
|
PrometheusExporter::Instrumentation::SidekiqQueue.start
|
383
|
+
PrometheusExporter::Instrumentation::SidekiqStats.start
|
389
384
|
end
|
390
385
|
end
|
391
386
|
```
|
392
387
|
|
393
|
-
|
388
|
+
* The middleware and death handler will generate job specific metrics (how many jobs ran? how many failed? how long did they take? how many are dead? how many were restarted?).
|
389
|
+
* The [`Process`](#per-process-stats) metrics provide basic ruby metrics.
|
390
|
+
* The `SidekiqProcess` metrics provide the concurrency and busy metrics for this process.
|
391
|
+
* The `SidekiqQueue` metrics provides size and latency for the queues run by this process.
|
392
|
+
* The `SidekiqStats` metrics provide general, global Sidekiq stats (size of Scheduled, Retries, Dead queues, total number of jobs, etc).
|
393
|
+
|
394
|
+
For `SidekiqQueue`, if you run more than one process for the same queues, note that the same metrics will be exposed by all the processes, just like the `SidekiqStats` will if you run more than one process of any kind. You might want use `avg` or `max` when consuming their metrics.
|
394
395
|
|
395
|
-
|
396
|
+
An alternative would be to expose these metrics in lone, long-lived process. Using a rake task, for example:
|
396
397
|
|
397
398
|
```ruby
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
399
|
+
task :sidekiq_metrics do
|
400
|
+
server = PrometheusExporter::Server::WebServer.new
|
401
|
+
server.start
|
402
|
+
|
403
|
+
PrometheusExporter::Client.default = PrometheusExporter::LocalClient.new(collector: server.collector)
|
404
|
+
|
405
|
+
PrometheusExporter::Instrumentation::SidekiqQueue.start(all_queues: true)
|
406
|
+
PrometheusExporter::Instrumentation::SidekiqStats.start
|
407
|
+
sleep
|
404
408
|
end
|
405
409
|
```
|
406
410
|
|
411
|
+
The `all_queues` parameter for `SidekiqQueue` will expose metrics for all queues.
|
412
|
+
|
407
413
|
Sometimes the Sidekiq server shuts down before it can send metrics, that were generated right before the shutdown, to the collector. Especially if you care about the `sidekiq_restarted_jobs_total` metric, it is a good idea to explicitly stop the client:
|
408
414
|
|
409
415
|
```ruby
|
@@ -447,7 +453,21 @@ Both metrics will have a `queue` label with the name of the queue.
|
|
447
453
|
| Gauge | `sidekiq_process_busy` | Number of busy workers for this process |
|
448
454
|
| Gauge | `sidekiq_process_concurrency` | Concurrency for this process |
|
449
455
|
|
450
|
-
Both metrics will include the labels `labels`, `queues`, `quiet`, `tag`, `hostname` and `identity`, as returned by the [Sidekiq API](https://github.com/mperham/sidekiq/wiki/API#processes).
|
456
|
+
Both metrics will include the labels `labels`, `queues`, `quiet`, `tag`, `hostname` and `identity`, as returned by the [Sidekiq Processes API](https://github.com/mperham/sidekiq/wiki/API#processes).
|
457
|
+
|
458
|
+
**PrometheusExporter::Instrumentation::SidekiqStats**
|
459
|
+
| Type | Name | Description |
|
460
|
+
| --- | --- | --- |
|
461
|
+
| Gauge | `sidekiq_stats_dead_size` | Size of the dead queue |
|
462
|
+
| Gauge | `sidekiq_stats_enqueued` | Number of enqueued jobs |
|
463
|
+
| Gauge | `sidekiq_stats_failed` | Number of failed jobs |
|
464
|
+
| Gauge | `sidekiq_stats_processed` | Total number of processed jobs |
|
465
|
+
| Gauge | `sidekiq_stats_processes_size` | Number of processes |
|
466
|
+
| Gauge | `sidekiq_stats_retry_size` | Size of the retries queue |
|
467
|
+
| Gauge | `sidekiq_stats_scheduled_size` | Size of the scheduled queue |
|
468
|
+
| Gauge | `sidekiq_stats_workers_size` | Number of jobs actively being processed |
|
469
|
+
|
470
|
+
Based on the [Sidekiq Stats API](https://github.com/mperham/sidekiq/wiki/API#stats).
|
451
471
|
|
452
472
|
_See [Metrics collected by Process Instrumentation](#metrics-collected-by-process-instrumentation) for a list of metrics the Process instrumentation will produce._
|
453
473
|
|
data/bin/prometheus_exporter
CHANGED
@@ -88,7 +88,7 @@ def run
|
|
88
88
|
end
|
89
89
|
|
90
90
|
if custom_collector_filename
|
91
|
-
|
91
|
+
require File.expand_path(custom_collector_filename)
|
92
92
|
found = false
|
93
93
|
|
94
94
|
base_klass = PrometheusExporter::Server::CollectorBase
|
@@ -108,7 +108,7 @@ def run
|
|
108
108
|
|
109
109
|
if custom_type_collectors_filenames.length > 0
|
110
110
|
custom_type_collectors_filenames.each do |t|
|
111
|
-
|
111
|
+
require File.expand_path(t)
|
112
112
|
end
|
113
113
|
|
114
114
|
ObjectSpace.each_object(Class) do |klass|
|
@@ -73,7 +73,7 @@ module PrometheusExporter::Instrumentation
|
|
73
73
|
# of the delayed extensions
|
74
74
|
# https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/extensions/class_methods.rb
|
75
75
|
begin
|
76
|
-
(target, method_name, _args) = YAML.load(msg['args'].first)
|
76
|
+
(target, method_name, _args) = YAML.load(msg['args'].first) # rubocop:disable Security/YAMLLoad
|
77
77
|
if target.class == Class
|
78
78
|
"#{target.name}##{method_name}"
|
79
79
|
else
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PrometheusExporter::Instrumentation
|
4
|
+
class SidekiqStats
|
5
|
+
def self.start(client: nil, frequency: 30)
|
6
|
+
client ||= PrometheusExporter::Client.default
|
7
|
+
sidekiq_stats_collector = new
|
8
|
+
|
9
|
+
Thread.new do
|
10
|
+
loop do
|
11
|
+
begin
|
12
|
+
client.send_json(sidekiq_stats_collector.collect)
|
13
|
+
rescue StandardError => e
|
14
|
+
STDERR.puts("Prometheus Exporter Failed To Collect Sidekiq Stats metrics #{e}")
|
15
|
+
ensure
|
16
|
+
sleep frequency
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def collect
|
23
|
+
{
|
24
|
+
type: 'sidekiq_stats',
|
25
|
+
stats: collect_stats
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def collect_stats
|
30
|
+
stats = ::Sidekiq::Stats.new
|
31
|
+
{
|
32
|
+
'dead_size' => stats.dead_size,
|
33
|
+
'enqueued' => stats.enqueued,
|
34
|
+
'failed' => stats.failed,
|
35
|
+
'processed' => stats.processed,
|
36
|
+
'processes_size' => stats.processes_size,
|
37
|
+
'retry_size' => stats.retry_size,
|
38
|
+
'scheduled_size' => stats.scheduled_size,
|
39
|
+
'workers_size' => stats.workers_size,
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -6,6 +6,7 @@ require_relative "instrumentation/method_profiler"
|
|
6
6
|
require_relative "instrumentation/sidekiq"
|
7
7
|
require_relative "instrumentation/sidekiq_queue"
|
8
8
|
require_relative "instrumentation/sidekiq_process"
|
9
|
+
require_relative "instrumentation/sidekiq_stats"
|
9
10
|
require_relative "instrumentation/delayed_job"
|
10
11
|
require_relative "instrumentation/puma"
|
11
12
|
require_relative "instrumentation/hutch"
|
@@ -58,6 +58,11 @@ class PrometheusExporter::Middleware
|
|
58
58
|
if params
|
59
59
|
action = params["action"]
|
60
60
|
controller = params["controller"]
|
61
|
+
elsif (cors = env["rack.cors"]) && cors.respond_to?(:preflight?) && cors.preflight?
|
62
|
+
# if the Rack CORS Middleware identifies the request as a preflight request,
|
63
|
+
# the stack doesn't get to the point where controllers/actions are defined
|
64
|
+
action = "preflight"
|
65
|
+
controller = "preflight"
|
61
66
|
end
|
62
67
|
|
63
68
|
{
|
@@ -15,6 +15,7 @@ module PrometheusExporter::Server
|
|
15
15
|
register_collector(SidekiqCollector.new)
|
16
16
|
register_collector(SidekiqQueueCollector.new)
|
17
17
|
register_collector(SidekiqProcessCollector.new)
|
18
|
+
register_collector(SidekiqStatsCollector.new)
|
18
19
|
register_collector(DelayedJobCollector.new)
|
19
20
|
register_collector(PumaCollector.new)
|
20
21
|
register_collector(HutchCollector.new)
|
@@ -26,7 +26,7 @@ module PrometheusExporter::Server
|
|
26
26
|
SIDEKIQ_PROCESS_GAUGES.map do |name, help|
|
27
27
|
if (value = metric[name])
|
28
28
|
gauge = gauges[name] ||= PrometheusExporter::Metric::Gauge.new("sidekiq_process_#{name}", help)
|
29
|
-
|
29
|
+
gauge.observe(value, labels)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PrometheusExporter::Server
|
4
|
+
class SidekiqStatsCollector < TypeCollector
|
5
|
+
MAX_SIDEKIQ_METRIC_AGE = 60
|
6
|
+
|
7
|
+
SIDEKIQ_STATS_GAUGES = {
|
8
|
+
'dead_size' => 'Size of dead the queue',
|
9
|
+
'enqueued' => 'Number of enqueued jobs',
|
10
|
+
'failed' => 'Number of failed jobs',
|
11
|
+
'processed' => 'Total number of processed jobs',
|
12
|
+
'processes_size' => 'Number of processes',
|
13
|
+
'retry_size' => 'Size of the retries queue',
|
14
|
+
'scheduled_size' => 'Size of the scheduled queue',
|
15
|
+
'workers_size' => 'Number of jobs actively being processed',
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
attr_reader :sidekiq_metrics, :gauges
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@sidekiq_metrics = []
|
22
|
+
@gauges = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def type
|
26
|
+
'sidekiq_stats'
|
27
|
+
end
|
28
|
+
|
29
|
+
def metrics
|
30
|
+
sidekiq_metrics.map do |metric|
|
31
|
+
SIDEKIQ_STATS_GAUGES.map do |name, help|
|
32
|
+
if (value = metric['stats'][name])
|
33
|
+
gauge = gauges[name] ||= PrometheusExporter::Metric::Gauge.new("sidekiq_stats_#{name}", help)
|
34
|
+
gauge.observe(value)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
gauges.values
|
40
|
+
end
|
41
|
+
|
42
|
+
def collect(object)
|
43
|
+
sidekiq_metrics << object
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -7,6 +7,7 @@ require_relative "server/process_collector"
|
|
7
7
|
require_relative "server/sidekiq_collector"
|
8
8
|
require_relative "server/sidekiq_queue_collector"
|
9
9
|
require_relative "server/sidekiq_process_collector"
|
10
|
+
require_relative "server/sidekiq_stats_collector"
|
10
11
|
require_relative "server/delayed_job_collector"
|
11
12
|
require_relative "server/collector_base"
|
12
13
|
require_relative "server/collector"
|
data/prometheus_exporter.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "rake", "~> 13.0"
|
32
32
|
spec.add_development_dependency "minitest", "~> 5.0"
|
33
33
|
spec.add_development_dependency "guard", "~> 2.0"
|
34
|
-
spec.add_development_dependency "mini_racer", "~> 0.
|
34
|
+
spec.add_development_dependency "mini_racer", "~> 0.5.0"
|
35
35
|
spec.add_development_dependency "guard-minitest", "~> 2.0"
|
36
36
|
spec.add_development_dependency "oj", "~> 3.0"
|
37
37
|
spec.add_development_dependency "rack-test", "~> 0.8.3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus_exporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webrick
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.5.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.5.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: guard-minitest
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,6 +245,7 @@ files:
|
|
245
245
|
- lib/prometheus_exporter/instrumentation/sidekiq.rb
|
246
246
|
- lib/prometheus_exporter/instrumentation/sidekiq_process.rb
|
247
247
|
- lib/prometheus_exporter/instrumentation/sidekiq_queue.rb
|
248
|
+
- lib/prometheus_exporter/instrumentation/sidekiq_stats.rb
|
248
249
|
- lib/prometheus_exporter/instrumentation/unicorn.rb
|
249
250
|
- lib/prometheus_exporter/metric.rb
|
250
251
|
- lib/prometheus_exporter/metric/base.rb
|
@@ -267,6 +268,7 @@ files:
|
|
267
268
|
- lib/prometheus_exporter/server/sidekiq_collector.rb
|
268
269
|
- lib/prometheus_exporter/server/sidekiq_process_collector.rb
|
269
270
|
- lib/prometheus_exporter/server/sidekiq_queue_collector.rb
|
271
|
+
- lib/prometheus_exporter/server/sidekiq_stats_collector.rb
|
270
272
|
- lib/prometheus_exporter/server/type_collector.rb
|
271
273
|
- lib/prometheus_exporter/server/unicorn_collector.rb
|
272
274
|
- lib/prometheus_exporter/server/web_collector.rb
|