prometheus_exporter 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8f8c9307f755aa00e95f323d2be11cdf6830f7e420c9bf70d90260e9bc81a85
4
- data.tar.gz: 216bedbba838f0a84391ef2e85b290aa596cf3c42d27b4cc6bce7a9fae8be01d
3
+ metadata.gz: c0089a6263d4775bbad13bf5714621eb7a353873468b020efc6ed216cbe6c917
4
+ data.tar.gz: f9676e32af68fff888a360a19f8cd55bbee2b855db11009ca3c7272eab58a449
5
5
  SHA512:
6
- metadata.gz: 3ad534e47314779c76eb9e80d5de23619cd0865c2337147188d7f2ddba3bff9a6c9cf630e20720899c4e7ef9c95bf1db317a719d08fc241850f902aceae1b5cf
7
- data.tar.gz: 6e71eab8cf6cdb049612c5afc404d6e399a142ee3eb5bbb3ae897e374ac6474d09f1b6c3ad94ab31f8d12fc52fc9e609a8b066051c89e44ea84be0fa0ec2cf0e
6
+ metadata.gz: 790b2ac6223cfa571c4b5c3404f79844a2f41e632151424448640d74a07f36fc4cb81e6935ec86de1208498536a1a115c2b62cb918aada3513823160287db556
7
+ data.tar.gz: a886c589c2e6decb57301754d654593216ad502f8690095d83749dba3b70243e98ac1b9a21071270777f7a5229f1852aa73c2d64a5029426669b4c8dfdf12805
data/CHANGELOG CHANGED
@@ -1,232 +1,409 @@
1
- 2.2.0 - 2024-12-05
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.3.1] - 2025-11-11
9
+
10
+ - FIX: get controller full path instead of controller name - Alex Platteeuw
11
+ - FEATURE: Secure PrometheusExporter scraping with SSL - Nicolas Rodriquez
12
+
13
+ ## [2.3.0] - 2025-08-01
14
+
15
+ - FEATURE: Added puma_busy_threads metric that provides a holistic view of server workload by calculating (active threads - idle threads) + queued requests
16
+ - FEATURE: adding marking_time and sweeping_time to GC metrics
17
+ - DEV: bumped up minimum Ruby version to 3.2
18
+ - FIX: better handling of malformed metrics
19
+ - FIX: get controller labels from controller, not params
20
+ - DEV: expose close on runner instance
21
+ - FEATURE: improved puma metrics
22
+
23
+ ## [2.2.0] - 2024-12-05
24
+
25
+ ### Added
2
26
 
3
- - FIX: Ensure socket is closed when error is raised while opening socket
4
27
  - Feature: Add Dalli::Client memcache metrics for web_collector
5
28
 
6
- 2.1.1 - 2024-06-19
29
+ ### Fixed
30
+
31
+ - FIX: Ensure socket is closed when error is raised while opening socket
32
+
33
+ ## [2.1.1] - 2024-06-19
34
+
35
+ ### Added
7
36
 
8
37
  - FEATURE: improve good_job instrumentation
9
- - FIX: improve Ruby 3.X support
10
38
  - FEATURE: imstrumentation for malloc / oldmalloc increace in GC stats
11
39
 
12
- 2.1.0 - 2024-01-08
40
+ ### Fixed
41
+
42
+ - FIX: improve Ruby 3.X support
43
+
44
+ ## [2.1.0] - 2024-01-08
45
+
46
+ ### Added
13
47
 
14
48
  - FEATURE: good_job instrumentation
49
+
50
+ ### Changed
51
+
15
52
  - PERF: improve performance of histogram
16
53
  - DEV: use new metric collector pattern so we reuse code between collectors
17
54
 
18
- 2.0.8 - 2023-01-20
55
+ ## [2.0.8] - 2023-01-20
56
+
57
+ ### Added
19
58
 
20
59
  - FEATURE: attempting to make our first docker release
21
60
 
22
- 2.0.7 - 2023-01-13
61
+ ## [2.0.7] - 2023-01-13
23
62
 
63
+ ### Added
24
64
  - FEATURE: allow binding server to both ipv4 and v6
65
+
66
+ ### Fixed
67
+
25
68
  - FIX: expire stale sidekiq metrics
26
69
 
27
70
 
28
- 2.0.6 - 2022-11-22
71
+ ## [2.0.6] - 2022-11-22
72
+
73
+ ### Fixed
29
74
 
30
75
  - FIX: use user specified labels over default in merge conflict
31
76
  - FIX: sidekiq stats collector memory leak
32
77
 
33
- 2.0.5 - 2022-11-15
78
+ ## [2.0.5] - 2022-11-15
79
+
80
+ ### Fixed
34
81
 
35
82
  - FIX: regression :prepend style instrumentation not working correctly
36
83
 
37
- 2.0.4 - 2022-11-10
84
+ ## [2.0.4] - 2022-11-10
85
+
86
+ ### Fixed
38
87
 
39
- - FIX/FEATURE: support for Redis 5 gem instrumentation
88
+ - FIX support for Redis 5 gem instrumentation
40
89
 
41
- 2.0.3 - 2022-05-23
90
+ ## [2.0.3] - 2022-05-23
91
+
92
+ ### Added
42
93
 
43
94
  - FEATURE: new ping endpoint for keepalive checks
95
+
96
+ ### Fixed
97
+
44
98
  - FIX: order histogram correctly for GCP support
45
99
  - FIX: improve sidekiq instrumentation
46
100
 
47
- 2.0.2 - 2022-02-25
101
+ ## [2.0.2] - 2022-02-25
102
+
103
+ ### Fixed
48
104
 
49
105
  - FIX: runner was not requiring unicorn integration correctly leading to a crash
50
106
 
51
- 2.0.1 - 2022-02-24
107
+ ## [2.0.1] - 2022-02-24
108
+
109
+ ### Fixed
52
110
 
53
111
  - FIX: ensure threads do not leak when calling #start repeatedly on instrumentation classes, this is an urgent patch for Puma integration
54
112
 
55
- 2.0.0 - 2022-02-18
113
+ ## [2.0.0] - 2022-02-18
114
+
115
+ ### Added
56
116
 
57
117
  - FEATURE: Add per worker custom labels
58
118
  - FEATURE: support custom histogram buckets
119
+
120
+ ### Fixed
121
+
59
122
  - FIX: all metrics are exposing status label, and not only `http_requests_total`
123
+
124
+ ### Changed
125
+
60
126
  - BREAKING: rename all `http_duration` metrics to `http_request_duration` to match prometheus official naming conventions (See https://prometheus.io/docs/practices/naming/#metric-names).
61
127
 
62
- 1.0.1 - 2021-12-22
128
+ ## [1.0.1] - 2021-12-22
129
+
130
+ ### Added
63
131
 
64
132
  - FEATURE: add labels to preflight requests
65
133
  - FEATURE: SidekiqStats metrics
134
+
135
+ ### Fixed
136
+
66
137
  - FIX: mintor refactors to Sidekiq metrics
67
138
 
68
- 1.0.0 - 2021-11-23
139
+ ## [1.0.0] - 2021-11-23
140
+
141
+ ### Added
69
142
 
70
- - BREAKING: rename metrics to match prometheus official naming conventions (See https://prometheus.io/docs/practices/naming/#metric-names)
71
143
  - FEATURE: Sidekiq process metrics
72
144
  - FEATURE: Allow collecting web metrics as histograms
145
+
146
+ ### Fixed
147
+
73
148
  - FIX: logger improved for web server
74
149
  - FIX: Remove job labels from DelayedJob queues
75
150
 
76
- 0.8.1 - 2021-08-04
151
+ ### Changed
152
+
153
+ - BREAKING: rename metrics to match prometheus official naming conventions (See https://prometheus.io/docs/practices/naming/#metric-names)
154
+
155
+
156
+ ## [0.8.1] - 2021-08-04
157
+
158
+ ### Added
77
159
 
78
160
  - FEATURE: swap from hardcoded STDERR to logger pattern (see README for details)
79
161
 
80
- 0.8.0 - 2021-07-05
162
+ ## [0.8.0] - 2021-07-05
163
+
164
+ ### Added
81
165
 
82
- - FIX: handle ThreadError more gracefully in cases where process shuts down
83
166
  - FEATURE: add job_name and queue_name labels to delayed job metrics
84
167
  - FEATURE: always scope puma metrics on hostname in collector
85
168
  - FEATURE: add customizable labels option to puma collector
86
169
  - FEATURE: support for Resque
87
- - DEV: Remove support for EOL ruby 2.5
88
- - FIX: Add source location to MethodProfiler patches
89
170
  - FEATURE: Improve Active Record instrumentation
90
171
  - FEATURE: Support HTTP_X_AMZN_TRACE_ID when supplied
91
172
 
92
- 0.7.0 - 2020-12-29
173
+ ### Fixed
174
+
175
+ - FIX: handle ThreadError more gracefully in cases where process shuts down
176
+ - FIX: Add source location to MethodProfiler patches
177
+
178
+ ### Removed
179
+
180
+ - DEV: Remove support for EOL ruby 2.5
181
+
182
+ ## [0.7.0] - 2020-12-29
183
+
184
+ ### Added
185
+
186
+ - FEATURE: clean pattern for overriding middleware labels was introduced (in README)
187
+
188
+ ### Fixed
189
+
190
+ - Fix: Better support for forking
191
+
192
+ ### Changed
93
193
 
94
194
  - Dev: Removed support from EOL rubies, only 2.5, 2.6, 2.7 and 3.0 are supported now.
95
195
  - Dev: Better support for Ruby 3.0, explicitly depending on webrick
96
196
  - Dev: Rails 6.1 instrumentation support
97
- - FEATURE: clean pattern for overriding middleware labels was introduced (in README)
98
- - Fix: Better support for forking
99
197
 
100
- 0.6.0 - 2020-11-17
198
+ ## [0.6.0] - 2020-11-17
199
+
200
+ ### Added
101
201
 
102
202
  - FEATURE: add support for basic-auth in the prometheus_exporter web server
103
203
 
104
- 0.5.3 - 2020-07-29
204
+ ## [0.5.3] - 2020-07-29
205
+
206
+ ### Added
105
207
 
106
208
  - FEATURE: added #remove to all metric types so users can remove specific labels if needed
107
209
 
108
- 0.5.2 - 2020-07-01
210
+ ## [0.5.2] - 2020-07-01
211
+
212
+ ### Added
109
213
 
110
214
  - FEATURE: expanded instrumentation for sidekiq
111
215
  - FEATURE: configurable default labels
112
216
 
113
- 0.5.1 - 2020-02-25
217
+ ## [0.5.1] - 2020-02-25
218
+
219
+ ### Added
114
220
 
115
221
  - FEATURE: Allow configuring the default client's host and port via environment variables
116
222
 
117
- 0.5.0 - 2020-02-14
223
+ ## [0.5.0] - 2020-02-14
224
+
225
+ ### Fixed
118
226
 
119
- - Breaking change: listen only to localhost by default to prevent unintended insecure configuration
120
227
  - FIX: Avoid calling `hostname` aggressively, instead cache it on the exporter instance
121
228
 
122
- 0.4.17 - 2020-01-13
229
+ ### Changed
230
+
231
+ - Breaking change: listen only to localhost by default to prevent unintended insecure configuration
232
+
233
+ ## [0.4.17] - 2020-01-13
234
+
235
+ ### Added
123
236
 
124
237
  - FEATURE: add support for `to_h` on all metrics which can be used to query existing key/values
125
238
 
126
- 0.4.16 - 2019-11-04
239
+ ## [0.4.16] - 2019-11-04
240
+
241
+ ### Added
127
242
 
128
243
  - FEATURE: Support #reset! on all metric types to reset a metric to default
129
244
 
130
- 0.4.15 - 2019-11-04
245
+ ## [0.4.15] - 2019-11-04
246
+
247
+ ### Added
131
248
 
132
249
  - FEATURE: Improve delayed job collector, add pending counts
133
250
  - FEATURE: New ActiveRecord collector (documented in readme)
134
251
  - FEATURE: Allow passing in histogram and summary options
135
252
  - FEATURE: Allow custom labels for unicorn collector
136
253
 
137
- 0.4.14 - 2019-09-10
254
+ ## [0.4.14] - 2019-09-10
255
+
256
+ ### Added
138
257
 
139
258
  - FEATURE: allow finding metrics by name RemoteMetric #find_registered_metric
259
+
260
+ ### Fixed
261
+
140
262
  - FIX: guard socket closing
141
263
 
142
- 0.4.13 - 2019-07-09
264
+ ## [0.4.13] - 2019-07-09
265
+
266
+ ### Fixed
143
267
 
144
268
  - Fix: Memory leak in unicorn and puma collectors
145
269
 
146
- 0.4.12 - 2019-05-30
270
+ ## [0.4.12] - 2019-05-30
271
+
272
+ ### Fixed
147
273
 
148
274
  - Fix: unicorn collector reporting incorrect number of unicorn workers
149
275
 
150
- 0.4.11 - 2019-05-15
276
+ ## [0.4.11] - 2019-05-15
277
+
278
+ ### Fixed
151
279
 
152
280
  - Fix: Handle stopping nil worker_threads in Client
281
+
282
+ ### Changed
283
+
153
284
  - Dev: add frozen string literals
154
285
 
155
- 0.4.10 - 2019-04-29
286
+ ## [0.4.10] - 2019-04-29
287
+
288
+ ### Fixed
156
289
 
157
290
  - Fix: Custom label support for puma collector
158
291
  - Fix: Raindrops socket collector not working correctly
159
292
 
160
- 0.4.9 - 2019-04-11
293
+ ## [0.4.9] - 2019-04-11
294
+
295
+ ### Fixed
161
296
 
162
297
  - Fix: Gem was not working correctly in Ruby 2.4 and below due to a syntax error
163
298
 
164
- 0.4.8 - 2019-04-10
299
+ ## [0.4.8] - 2019-04-10
300
+
301
+ ### Added
165
302
 
166
303
  - Feature: added helpers for instrumenting unicorn using raindrops
167
304
 
168
- 0.4.7 - 2019-04-08
305
+ ## [0.4.7] - 2019-04-08
306
+
307
+ ### Fixed
169
308
 
170
309
  - Fix: collector was not escaping " \ and \n correctly. This could lead
171
310
  to a corrupt payload in some cases.
172
311
 
173
- 0.4.6 - 2019-04-02
312
+ ## [0.4.6] - 2019-04-02
313
+
314
+ ### Added
174
315
 
175
316
  - Feature: Allow resetting a counter
176
317
  - Feature: Add sidekiq metrics: restarted, dead jobs counters
318
+
319
+ ### Fixed
320
+
177
321
  - Fix: Client shutting down before sending metrics to collector
178
322
 
179
- 0.4.5 - 2019-02-14
323
+ ## [0.4.5] - 2019-02-14
324
+
325
+ ### Added
180
326
 
181
327
  - Feature: Allow process collector to ship custom labels for all process metrics
328
+
329
+ ### Fixed
330
+
182
331
  - Fix: Always scope process metrics on hostname in collector
183
332
 
184
- 0.4.4 - 2019-02-13
333
+ ## [0.4.4] - 2019-02-13
334
+
335
+ ### Added
185
336
 
186
337
  - Feature: add support for local metric collection without using HTTP
187
338
 
188
- 0.4.3 - 2019-02-11
339
+ ## [0.4.3] - 2019-02-11
340
+
341
+ ### Added
189
342
 
190
343
  - Feature: Add alias for Gauge #observe called #set, this makes it a bit easier to migrate from prom
191
344
  - Feature: Add increment and decrement to Counter
192
345
 
193
- 0.4.2 - 2018-11-30
346
+ ## [0.4.2] - 2018-11-30
347
+
348
+ ### Fixed
194
349
 
195
- - Fix/Feature: setting a Gauge to nil will remove Gauge (setting to non numeric will raise)
350
+ - Fix: setting a Gauge to nil will remove Gauge (setting to non numeric will raise)
196
351
 
197
- 0.4.0 - 2018-10-23
352
+ ## [0.4.0] - 2018-10-23
353
+
354
+ ### Added
198
355
 
199
356
  - Feature: histogram support
200
357
  - Feature: custom quantile support for summary
201
358
  - Feature: Puma metrics
359
+
360
+ ### Fixed
361
+
202
362
  - Fix: delayed job metrics
203
363
 
204
- 0.3.4 - 2018-10-02
364
+ ## [0.3.4] - 2018-10-02
365
+
366
+ ### Fixed
205
367
 
206
368
  - Fix: custom collector via CLI was not working correctly
207
369
 
208
- 0.3.3
370
+ ## [0.3.3]
371
+
372
+ ### Added
209
373
 
210
374
  - Feature: Add more metrics to delayed job collector
211
375
 
212
- 0.3.2
376
+ ## [0.3.2]
377
+
378
+ ### Added
213
379
 
214
380
  - Feature: Add posibility to set custom_labels on multi process mode
215
381
 
216
- 0.3.1
382
+ ## [0.3.1]
383
+
384
+ ### Changed
217
385
 
218
386
  - Allow runner to accept a --timeout var
219
387
  - Allow runner to accept a blank prefix
220
388
 
221
- 0.3.0
389
+ ## [0.3.0]
390
+
391
+ ### Changed
222
392
 
223
393
  - Breaking change: Follow Prometheus metric [naming conventions](https://prometheus.io/docs/practices/naming/#metric-names)
224
394
 
225
- 0.1.15 - 2018-02-19
395
+ ## [0.1.15] - 2018-02-19
396
+
397
+ ### Added
226
398
 
227
399
  - Feature: Prefer to use oj if it is loadable
228
400
 
229
- 0.1.14 - 2018-02-17
401
+ ## [0.1.14] - 2018-02-17
402
+
403
+ ### Added
230
404
 
231
- - Fix: error when shipping summary metric with no labels
232
405
  - Feature: runner was extracted so it can be reused @304
406
+
407
+ ### Fixed
408
+
409
+ - Fix: error when shipping summary metric with no labels
data/README.md CHANGED
@@ -98,8 +98,8 @@ server.collector.register_metric(counter)
98
98
  server.collector.register_metric(summary)
99
99
  server.collector.register_metric(histogram)
100
100
 
101
- gauge.observe(get_rss)
102
- gauge.observe(get_rss)
101
+ gauge.observe(server.get_rss)
102
+ gauge.observe(server.get_rss)
103
103
 
104
104
  counter.observe(1, route: 'test/route')
105
105
  counter.observe(1, route: 'another/route')
@@ -373,6 +373,8 @@ end
373
373
  | Counter | `major_gc_ops_total` | Major GC operations by process |
374
374
  | Counter | `minor_gc_ops_total` | Minor GC operations by process |
375
375
  | Counter | `allocated_objects_total` | Total number of allocated objects by process |
376
+ | Gauge | `marking_time` | Marking time spent (Ruby 3.3 minimum) |
377
+ | Gauge | `sweeping_time` | Sweeping time spent (Ruby 3.3 minimum) |
376
378
 
377
379
  _Metrics marked with * are only collected when `MiniRacer` is defined._
378
380
 
@@ -609,15 +611,16 @@ end
609
611
 
610
612
  #### Metrics collected by Puma Instrumentation
611
613
 
612
- | Type | Name | Description |
613
- | --- | --- | --- |
614
- | Gauge | `puma_workers` | Number of puma workers |
615
- | Gauge | `puma_booted_workers` | Number of puma workers booted |
616
- | Gauge | `puma_old_workers` | Number of old puma workers |
617
- | Gauge | `puma_running_threads` | Number of puma threads currently running |
618
- | Gauge | `puma_request_backlog` | Number of requests waiting to be processed by a puma thread |
619
- | Gauge | `puma_thread_pool_capacity` | Number of puma threads available at current scale |
620
- | Gauge | `puma_max_threads` | Number of puma threads at available at max scale |
614
+ | Type | Name | Description |
615
+ | --- | --- | --- |
616
+ | Gauge | `puma_workers` | Number of puma workers |
617
+ | Gauge | `puma_booted_workers` | Number of puma workers booted |
618
+ | Gauge | `puma_old_workers` | Number of old puma workers |
619
+ | Gauge | `puma_running_threads` | How many threads are spawned. A spawned thread may be busy processing a request or waiting for a new request |
620
+ | Gauge | `puma_request_backlog` | Number of requests waiting to be processed by a puma thread |
621
+ | Gauge | `puma_thread_pool_capacity` | Number of puma threads available at current scale |
622
+ | Gauge | `puma_max_threads` | Number of puma threads at available at max scale |
623
+ | Gauge | `puma_busy_threads` | Running - how many threads are waiting to receive work + how many requests are waiting for a thread to pick them up |
621
624
 
622
625
  All metrics may have a `phase` label and all custom labels provided with the `labels` option.
623
626
 
@@ -71,6 +71,13 @@ def run
71
71
  opt.on('--logger-path PATH', String, '(optional) Path to file for logger output. Defaults to STDERR') do |o|
72
72
  options[:logger_path] = o
73
73
  end
74
+
75
+ opt.on('--tls-key-file PATH', String, "(optional) Enable server TLS using a private key PATH") do |o|
76
+ options[:tls_key_file] = o
77
+ end
78
+ opt.on('--tls-cert-file PATH', String, "(optional) Enable server TLS using a certificate PATH") do |o|
79
+ options[:tls_cert_file] = o
80
+ end
74
81
  end.parse!
75
82
 
76
83
  logger = Logger.new(options[:logger_path])
@@ -56,11 +56,15 @@ module PrometheusExporter
56
56
  port: ENV.fetch("PROMETHEUS_EXPORTER_PORT", PrometheusExporter::DEFAULT_PORT),
57
57
  max_queue_size: nil,
58
58
  thread_sleep: 0.5,
59
+ connect_timeout: nil,
59
60
  json_serializer: nil,
60
61
  custom_labels: nil,
61
62
  logger: Logger.new(STDERR),
62
63
  log_level: Logger::WARN,
63
- process_queue_once_and_stop: false
64
+ process_queue_once_and_stop: false,
65
+ tls_ca_file: nil,
66
+ tls_cert_file: nil,
67
+ tls_key_file: nil
64
68
  )
65
69
  @logger = logger
66
70
  @logger.level = log_level
@@ -83,11 +87,18 @@ module PrometheusExporter
83
87
  @worker_thread = nil
84
88
  @mutex = Mutex.new
85
89
  @thread_sleep = thread_sleep
90
+ @connect_timeout = connect_timeout
86
91
 
87
92
  @json_serializer = json_serializer == :oj ? PrometheusExporter::OjCompat : JSON
88
93
 
89
94
  @custom_labels = custom_labels
90
95
  @process_queue_once_and_stop = process_queue_once_and_stop
96
+
97
+ @tls_ca_file = tls_ca_file
98
+ @tls_cert_file = tls_cert_file
99
+ @tls_key_file = tls_key_file
100
+
101
+ @ssl_context = build_ssl_context if use_ssl?
91
102
  end
92
103
 
93
104
  def custom_labels=(custom_labels)
@@ -228,7 +239,14 @@ module PrometheusExporter
228
239
 
229
240
  close_socket_if_old!
230
241
  if !@socket
231
- @socket = TCPSocket.new @host, @port
242
+ @socket = TCPSocket.new @host, @port, connect_timeout: @connect_timeout
243
+
244
+ if use_ssl?
245
+ @socket = OpenSSL::SSL::SSLSocket.new(@socket, @ssl_context)
246
+ @socket.sync_close = true
247
+ @socket.connect
248
+ end
249
+
232
250
  @socket.write("POST /send-metrics HTTP/1.1\r\n")
233
251
  @socket.write("Transfer-Encoding: chunked\r\n")
234
252
  @socket.write("Host: #{@host}\r\n")
@@ -246,6 +264,20 @@ module PrometheusExporter
246
264
  raise
247
265
  end
248
266
 
267
+ def use_ssl?
268
+ @tls_ca_file && @tls_cert_file && @tls_key_file
269
+ end
270
+
271
+ def build_ssl_context
272
+ require "openssl"
273
+ ssl_context = OpenSSL::SSL::SSLContext.new()
274
+ ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@tls_cert_file))
275
+ ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@tls_key_file))
276
+ ssl_context.ca_file = @tls_ca_file
277
+ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
278
+ ssl_context
279
+ end
280
+
249
281
  def wait_for_empty_queue_with_timeout(timeout_seconds)
250
282
  start_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
251
283
  while @queue.length > 0
@@ -40,6 +40,8 @@ module PrometheusExporter::Instrumentation
40
40
 
41
41
  def call(job, max_attempts, enqueued_count, pending_count, include_module_name, *args, &block)
42
42
  success = false
43
+ job_name = job.handler.to_s.match(JOB_CLASS_REGEXP).to_a[include_module_name ? 1 : 2].to_s
44
+ job_name ||= job.try(:name)
43
45
  start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
44
46
  latency = Time.current - job.run_at
45
47
  attempts = job.attempts + 1 # Increment because we're adding the current attempt
@@ -51,7 +53,7 @@ module PrometheusExporter::Instrumentation
51
53
 
52
54
  @client.send_json(
53
55
  type: "delayed_job",
54
- name: job.handler.to_s.match(JOB_CLASS_REGEXP).to_a[include_module_name ? 1 : 2].to_s,
56
+ name: job_name,
55
57
  queue_name: job.queue,
56
58
  success: success,
57
59
  duration: duration,
@@ -62,6 +62,8 @@ module PrometheusExporter::Instrumentation
62
62
  metric[:rss] = rss
63
63
  end
64
64
 
65
+ SWEEPING_AND_MARKING = RUBY_VERSION >= "3.3.0"
66
+
65
67
  def collect_gc_stats(metric)
66
68
  stat = GC.stat
67
69
  metric[:heap_live_slots] = stat[:heap_live_slots]
@@ -71,6 +73,10 @@ module PrometheusExporter::Instrumentation
71
73
  metric[:allocated_objects_total] = stat[:total_allocated_objects]
72
74
  metric[:malloc_increase_bytes_limit] = stat[:malloc_increase_bytes_limit]
73
75
  metric[:oldmalloc_increase_bytes_limit] = stat[:oldmalloc_increase_bytes_limit]
76
+ if SWEEPING_AND_MARKING
77
+ metric[:marking_time] = stat[:marking_time]
78
+ metric[:sweeping_time] = stat[:sweeping_time]
79
+ end
74
80
  end
75
81
 
76
82
  def collect_v8_stats(metric)
@@ -61,11 +61,13 @@ module PrometheusExporter::Instrumentation
61
61
  metric[:running_threads] ||= 0
62
62
  metric[:thread_pool_capacity] ||= 0
63
63
  metric[:max_threads] ||= 0
64
+ metric[:busy_threads] ||= 0
64
65
 
65
66
  metric[:request_backlog] += status["backlog"]
66
67
  metric[:running_threads] += status["running"]
67
68
  metric[:thread_pool_capacity] += status["pool_capacity"]
68
69
  metric[:max_threads] += status["max_threads"]
70
+ metric[:busy_threads] += status["busy_threads"]
69
71
  end
70
72
  end
71
73
  end
@@ -74,11 +74,11 @@ class PrometheusExporter::Middleware
74
74
  end
75
75
 
76
76
  def default_labels(env, result)
77
- params = env["action_dispatch.request.parameters"]
77
+ controller_instance = env["action_controller.instance"]
78
78
  action = controller = nil
79
- if params
80
- action = params["action"]
81
- controller = params["controller"]
79
+ if controller_instance
80
+ action = controller_instance.action_name
81
+ controller = controller_instance.controller_path
82
82
  elsif (cors = env["rack.cors"]) && cors.respond_to?(:preflight?) && cors.preflight?
83
83
  # if the Rack CORS Middleware identifies the request as a preflight request,
84
84
  # the stack doesn't get to the point where controllers/actions are defined