prometheus_exporter 2.1.0 → 2.1.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 +7 -6
- data/.rubocop +1 -0
- data/.rubocop.yml +12 -1
- data/CHANGELOG +7 -1
- data/README.md +13 -2
- data/bin/prometheus_exporter +2 -2
- data/gemfiles/ar_70.gemfile +2 -0
- data/gemfiles/ar_71.gemfile +7 -0
- data/lib/prometheus_exporter/instrumentation/delayed_job.rb +6 -5
- data/lib/prometheus_exporter/instrumentation/method_profiler.rb +4 -4
- data/lib/prometheus_exporter/instrumentation/process.rb +2 -0
- data/lib/prometheus_exporter/middleware.rb +1 -1
- data/lib/prometheus_exporter/server/process_collector.rb +2 -0
- data/lib/prometheus_exporter/version.rb +1 -1
- data/prometheus_exporter.gemspec +5 -5
- metadata +15 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5381fb78e6440d77a61269f3bf7c40a84b44a53594d687db4a683be3cb82725
|
4
|
+
data.tar.gz: 18216fbeae6978d5427fa9f97a67bbf3f0ee36e92091a2606b2dadcaa6497d83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 626d1f7c05e5bf21bc499e69fd1ab0d73c94c5a565ac7eae81ec9d43fc93f6cf96b83a6fd72b25846e49371079a9c87a497e719d74c20dfa57c0fb5cbe4507e5
|
7
|
+
data.tar.gz: b43a57442d6326648cbc3539c50400556575e425756358d45ad39832e099671ca617ea66b6754d16d66693b9fbdf9045b96a95713b36f1f135ab8ab0e38a6d0b
|
data/.github/workflows/ci.yml
CHANGED
@@ -27,15 +27,16 @@ jobs:
|
|
27
27
|
strategy:
|
28
28
|
fail-fast: false
|
29
29
|
matrix:
|
30
|
-
ruby: ['3.
|
31
|
-
activerecord: [
|
30
|
+
ruby: ['3.1', '3.2', '3.3']
|
31
|
+
activerecord: [61, 70, 71]
|
32
32
|
|
33
33
|
steps:
|
34
|
-
- uses: actions/checkout@
|
34
|
+
- uses: actions/checkout@v4
|
35
35
|
|
36
36
|
- uses: ruby/setup-ruby@v1
|
37
37
|
with:
|
38
38
|
ruby-version: ${{ matrix.ruby }}
|
39
|
+
bundler: latest
|
39
40
|
bundler-cache: true
|
40
41
|
|
41
42
|
- name: Rubocop
|
@@ -50,10 +51,10 @@ jobs:
|
|
50
51
|
runs-on: ubuntu-latest
|
51
52
|
|
52
53
|
outputs:
|
53
|
-
new_version_published: ${{ steps.release.outputs.
|
54
|
+
new_version_published: ${{ steps.release.outputs.new_version }}
|
54
55
|
|
55
56
|
steps:
|
56
|
-
- uses: actions/checkout@
|
57
|
+
- uses: actions/checkout@v4
|
57
58
|
|
58
59
|
- name: Release gem
|
59
60
|
id: release
|
@@ -70,7 +71,7 @@ jobs:
|
|
70
71
|
timeout-minutes: 20
|
71
72
|
|
72
73
|
steps:
|
73
|
-
- uses: actions/checkout@
|
74
|
+
- uses: actions/checkout@v4
|
74
75
|
- uses: docker/setup-qemu-action@v2
|
75
76
|
- uses: docker/setup-buildx-action@v2
|
76
77
|
|
data/.rubocop
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--ignore-unrecognized-cops
|
data/.rubocop.yml
CHANGED
@@ -4,4 +4,15 @@ inherit_gem:
|
|
4
4
|
AllCops:
|
5
5
|
Exclude:
|
6
6
|
- 'gemfiles/**/*'
|
7
|
-
- 'vendor/**/*'
|
7
|
+
- 'vendor/**/*'
|
8
|
+
|
9
|
+
Discourse/Plugins/NoMonkeyPatching:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Discourse/Plugins/NamespaceMethods:
|
13
|
+
Exclude:
|
14
|
+
- bin/prometheus_exporter
|
15
|
+
|
16
|
+
Style/InvertibleUnlessCondition:
|
17
|
+
Exclude:
|
18
|
+
- '*.gemspec'
|
data/CHANGELOG
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.1 - 2024-06-19
|
2
|
+
|
3
|
+
- FEATURE: improve good_job instrumentation
|
4
|
+
- FIX: improve Ruby 3.X support
|
5
|
+
- FEATURE: imstrumentation for malloc / oldmalloc increace in GC stats
|
6
|
+
|
7
|
+
2.1.0 - 2024-01-08
|
2
8
|
|
3
9
|
- FEATURE: good_job instrumentation
|
4
10
|
- PERF: improve performance of histogram
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ To learn more see [Instrumenting Rails with Prometheus](https://samsaffron.com/a
|
|
40
40
|
|
41
41
|
## Requirements
|
42
42
|
|
43
|
-
Minimum Ruby of version
|
43
|
+
Minimum Ruby of version 3.0.0 is required, Ruby 2.7 is EOL as of March 31st 2023.
|
44
44
|
|
45
45
|
## Migrating from v0.x
|
46
46
|
|
@@ -583,6 +583,17 @@ The puma metrics are using the `Puma.stats` method and hence need to be started
|
|
583
583
|
workers has been booted and from a Puma thread otherwise the metrics won't be accessible.
|
584
584
|
The easiest way to gather this metrics is to put the following in your `puma.rb` config:
|
585
585
|
|
586
|
+
For Puma single mode
|
587
|
+
```ruby
|
588
|
+
# puma.rb config
|
589
|
+
require 'prometheus_exporter/instrumentation'
|
590
|
+
# optional check, avoids spinning up and down threads per worker
|
591
|
+
if !PrometheusExporter::Instrumentation::Puma.started?
|
592
|
+
PrometheusExporter::Instrumentation::Puma.start
|
593
|
+
end
|
594
|
+
```
|
595
|
+
|
596
|
+
For Puma clustered mode
|
586
597
|
```ruby
|
587
598
|
# puma.rb config
|
588
599
|
after_worker_boot do
|
@@ -884,7 +895,7 @@ prometheus_exporter -p 8080 \
|
|
884
895
|
--prefix 'foo_'
|
885
896
|
```
|
886
897
|
|
887
|
-
You can use `-b` option to bind the `prometheus_exporter` web server to any IPv4 interface with `-b 0.0.0.0`,
|
898
|
+
You can use `-b` option to bind the `prometheus_exporter` web server to any IPv4 interface with `-b 0.0.0.0`,
|
888
899
|
any IPv6 interface with `-b ::`, or `-b ANY` to any IPv4/IPv6 interfaces available on your host system.
|
889
900
|
|
890
901
|
#### Enabling Basic Authentication
|
data/bin/prometheus_exporter
CHANGED
@@ -74,7 +74,7 @@ def run
|
|
74
74
|
end.parse!
|
75
75
|
|
76
76
|
logger = Logger.new(options[:logger_path])
|
77
|
-
logger.level = Logger::
|
77
|
+
logger.level = Logger::INFO
|
78
78
|
|
79
79
|
if options.has_key?(:realm) && !options.has_key?(:auth)
|
80
80
|
logger.warn "Providing REALM without AUTH has no effect"
|
@@ -121,7 +121,7 @@ def run
|
|
121
121
|
|
122
122
|
runner = PrometheusExporter::Server::Runner.new(options)
|
123
123
|
|
124
|
-
|
124
|
+
logger.info "Starting prometheus exporter on #{runner.bind}:#{runner.port}"
|
125
125
|
runner.start
|
126
126
|
sleep
|
127
127
|
end
|
data/gemfiles/ar_70.gemfile
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module PrometheusExporter::Instrumentation
|
4
4
|
class DelayedJob
|
5
|
-
JOB_CLASS_REGEXP = %r{job_class: (\w+:{0,2})+}.freeze
|
5
|
+
JOB_CLASS_REGEXP = %r{job_class: ((\w+:{0,2})+)}.freeze
|
6
6
|
|
7
7
|
class << self
|
8
|
-
def register_plugin(client: nil)
|
8
|
+
def register_plugin(client: nil, include_module_name: false)
|
9
9
|
instrumenter = self.new(client: client)
|
10
10
|
return unless defined?(Delayed::Plugin)
|
11
11
|
|
@@ -15,7 +15,8 @@ module PrometheusExporter::Instrumentation
|
|
15
15
|
max_attempts = Delayed::Worker.max_attempts
|
16
16
|
enqueued_count = Delayed::Job.where(queue: job.queue).count
|
17
17
|
pending_count = Delayed::Job.where(attempts: 0, locked_at: nil, queue: job.queue).count
|
18
|
-
instrumenter.call(job, max_attempts, enqueued_count, pending_count,
|
18
|
+
instrumenter.call(job, max_attempts, enqueued_count, pending_count, include_module_name,
|
19
|
+
*args, &block)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -28,7 +29,7 @@ module PrometheusExporter::Instrumentation
|
|
28
29
|
@client = client || PrometheusExporter::Client.default
|
29
30
|
end
|
30
31
|
|
31
|
-
def call(job, max_attempts, enqueued_count, pending_count, *args, &block)
|
32
|
+
def call(job, max_attempts, enqueued_count, pending_count, include_module_name, *args, &block)
|
32
33
|
success = false
|
33
34
|
start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
|
34
35
|
latency = Time.current - job.run_at
|
@@ -41,7 +42,7 @@ module PrometheusExporter::Instrumentation
|
|
41
42
|
|
42
43
|
@client.send_json(
|
43
44
|
type: "delayed_job",
|
44
|
-
name: job.handler.to_s.match(JOB_CLASS_REGEXP).to_a[1].to_s,
|
45
|
+
name: job.handler.to_s.match(JOB_CLASS_REGEXP).to_a[include_module_name ? 1 : 2].to_s,
|
45
46
|
queue_name: job.queue,
|
46
47
|
success: success,
|
47
48
|
duration: duration,
|
@@ -44,7 +44,7 @@ class PrometheusExporter::Instrumentation::MethodProfiler
|
|
44
44
|
patch_source_line = __LINE__ + 3
|
45
45
|
patches = methods.map do |method_name|
|
46
46
|
<<~RUBY
|
47
|
-
def #{method_name}(
|
47
|
+
def #{method_name}(...)
|
48
48
|
unless prof = Thread.current[:_method_profiler]
|
49
49
|
return super
|
50
50
|
end
|
@@ -75,13 +75,13 @@ class PrometheusExporter::Instrumentation::MethodProfiler
|
|
75
75
|
<<~RUBY
|
76
76
|
unless defined?(#{method_name}__mp_unpatched)
|
77
77
|
alias_method :#{method_name}__mp_unpatched, :#{method_name}
|
78
|
-
def #{method_name}(
|
78
|
+
def #{method_name}(...)
|
79
79
|
unless prof = Thread.current[:_method_profiler]
|
80
|
-
return #{method_name}__mp_unpatched(
|
80
|
+
return #{method_name}__mp_unpatched(...)
|
81
81
|
end
|
82
82
|
begin
|
83
83
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
84
|
-
#{method_name}__mp_unpatched(
|
84
|
+
#{method_name}__mp_unpatched(...)
|
85
85
|
ensure
|
86
86
|
data = (prof[:#{name}] ||= {duration: 0.0, calls: 0})
|
87
87
|
data[:duration] += Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
@@ -63,6 +63,8 @@ module PrometheusExporter::Instrumentation
|
|
63
63
|
metric[:major_gc_ops_total] = stat[:major_gc_count]
|
64
64
|
metric[:minor_gc_ops_total] = stat[:minor_gc_count]
|
65
65
|
metric[:allocated_objects_total] = stat[:total_allocated_objects]
|
66
|
+
metric[:malloc_increase_bytes_limit] = stat[:malloc_increase_bytes_limit]
|
67
|
+
metric[:oldmalloc_increase_bytes_limit] = stat[:oldmalloc_increase_bytes_limit]
|
66
68
|
end
|
67
69
|
|
68
70
|
def collect_v8_stats(metric)
|
@@ -23,7 +23,7 @@ class PrometheusExporter::Middleware
|
|
23
23
|
end
|
24
24
|
if defined? PG::Connection
|
25
25
|
MethodProfiler.patch(PG::Connection, [
|
26
|
-
:exec, :async_exec, :exec_prepared, :send_query_prepared, :query
|
26
|
+
:exec, :async_exec, :exec_prepared, :exec_params, :send_query_prepared, :query
|
27
27
|
], :sql, instrument: config[:instrument])
|
28
28
|
end
|
29
29
|
if defined? Mysql2::Client
|
@@ -13,6 +13,8 @@ module PrometheusExporter::Server
|
|
13
13
|
v8_physical_size: "Physical size consumed by V8 heaps.",
|
14
14
|
v8_heap_count: "Number of V8 contexts running.",
|
15
15
|
rss: "Total RSS used by process.",
|
16
|
+
malloc_increase_bytes_limit: 'Limit before Ruby triggers a GC against current objects (bytes).',
|
17
|
+
oldmalloc_increase_bytes_limit: 'Limit before Ruby triggers a major GC against old objects (bytes).'
|
16
18
|
}
|
17
19
|
|
18
20
|
PROCESS_COUNTERS = {
|
data/prometheus_exporter.gemspec
CHANGED
@@ -27,14 +27,14 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "rubocop", ">= 0.69"
|
28
28
|
spec.add_development_dependency "bundler", ">= 2.1.4"
|
29
29
|
spec.add_development_dependency "rake", "~> 13.0"
|
30
|
-
spec.add_development_dependency "minitest", "~> 5.
|
30
|
+
spec.add_development_dependency "minitest", "~> 5.23.0"
|
31
31
|
spec.add_development_dependency "guard", "~> 2.0"
|
32
|
-
spec.add_development_dependency "mini_racer", "~> 0.
|
32
|
+
spec.add_development_dependency "mini_racer", "~> 0.12.0"
|
33
33
|
spec.add_development_dependency "guard-minitest", "~> 2.0"
|
34
34
|
spec.add_development_dependency "oj", "~> 3.0"
|
35
|
-
spec.add_development_dependency "rack-test", "~>
|
35
|
+
spec.add_development_dependency "rack-test", "~> 2.1.0"
|
36
36
|
spec.add_development_dependency "minitest-stub-const", "~> 0.6"
|
37
|
-
spec.add_development_dependency "rubocop-discourse", "
|
37
|
+
spec.add_development_dependency "rubocop-discourse", ">= 3"
|
38
38
|
spec.add_development_dependency "appraisal", "~> 2.3"
|
39
39
|
spec.add_development_dependency "activerecord", "~> 6.0.0"
|
40
40
|
spec.add_development_dependency "redis", "> 5"
|
@@ -42,5 +42,5 @@ Gem::Specification.new do |spec|
|
|
42
42
|
if !RUBY_ENGINE == 'jruby'
|
43
43
|
spec.add_development_dependency "raindrops", "~> 0.19"
|
44
44
|
end
|
45
|
-
spec.required_ruby_version = '>=
|
45
|
+
spec.required_ruby_version = '>= 3.0.0'
|
46
46
|
end
|
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: 2.1.
|
4
|
+
version: 2.1.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: 2024-
|
11
|
+
date: 2024-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webrick
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 5.
|
75
|
+
version: 5.23.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 5.
|
82
|
+
version: 5.23.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: guard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.12.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.12.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: guard-minitest
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 2.1.0
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 2.1.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: minitest-stub-const
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,16 +168,16 @@ dependencies:
|
|
168
168
|
name: rubocop-discourse
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- - "
|
171
|
+
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
173
|
+
version: '3'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - "
|
178
|
+
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
180
|
+
version: '3'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: appraisal
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,6 +244,7 @@ extra_rdoc_files: []
|
|
244
244
|
files:
|
245
245
|
- ".github/workflows/ci.yml"
|
246
246
|
- ".gitignore"
|
247
|
+
- ".rubocop"
|
247
248
|
- ".rubocop.yml"
|
248
249
|
- Appraisals
|
249
250
|
- CHANGELOG
|
@@ -261,6 +262,7 @@ files:
|
|
261
262
|
- gemfiles/ar_60.gemfile
|
262
263
|
- gemfiles/ar_61.gemfile
|
263
264
|
- gemfiles/ar_70.gemfile
|
265
|
+
- gemfiles/ar_71.gemfile
|
264
266
|
- lib/prometheus_exporter.rb
|
265
267
|
- lib/prometheus_exporter/client.rb
|
266
268
|
- lib/prometheus_exporter/instrumentation.rb
|
@@ -321,7 +323,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
321
323
|
requirements:
|
322
324
|
- - ">="
|
323
325
|
- !ruby/object:Gem::Version
|
324
|
-
version:
|
326
|
+
version: 3.0.0
|
325
327
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
326
328
|
requirements:
|
327
329
|
- - ">="
|