inst-jobs-statsd 3.0.2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4a9d57f59dc527218751eb536cac69af6d5eb257d216d8b01cd5f00de7d10b8
|
4
|
+
data.tar.gz: 7398542a12623da8a74be2d1158d25f48bdb6b68433532608b10e2dbbec21c78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd829e71ac4403783556005c4ab5cf2fb2eed80238f5f2e8785c6297a5b1330f7ecda868e88a69b92cd197c53ebfe8445b202e24f81bfd852b9db6105fd68956
|
7
|
+
data.tar.gz: cb5c46e89d724dab97743d5c3db895a3f8e8d3a5857d9a4af443ba91ee89a505879f7b3ec6e8f670fcaeb0b48957567c5487d4c9d6facf0ce9a22d5a6958f6c8
|
@@ -14,8 +14,9 @@ module InstJobsStatsd
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.report_failed_depth
|
17
|
-
|
18
|
-
|
17
|
+
count_by_queue = Delayed::Job::Failed.group(:queue).count
|
18
|
+
|
19
|
+
Periodic.report_gauge_by_queue(:failed_depth, count_by_queue)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -20,10 +20,7 @@ module InstJobsStatsd
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.report_queue_depth
|
23
|
-
|
24
|
-
scope = queued_jobs_scope
|
25
|
-
count = scope.count
|
26
|
-
Periodic.report_gauge(:queue_depth, count)
|
23
|
+
Periodic.report_gauge_by_queue(:queue_depth, queued_jobs_scope.count)
|
27
24
|
end
|
28
25
|
|
29
26
|
# Limit the jobs included in this gauge to prevent blowing up
|
@@ -34,16 +31,20 @@ module InstJobsStatsd
|
|
34
31
|
# the count is capped, the metric will continue to grow
|
35
32
|
# if the queue is actually stalled
|
36
33
|
def self.report_queue_age
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
jobs_run_at_by_queue = queued_jobs_scope.limit(10_000).pluck(:queue, "ARRAY_AGG(run_at)").to_h
|
35
|
+
age_secs_by_queue = jobs_run_at_by_queue.transform_values { |v| v.map { |t| Delayed::Job.db_time_now - t } }
|
36
|
+
age_max_by_queue = age_secs_by_queue.transform_values(&:max)
|
37
|
+
age_total_by_queue = age_secs_by_queue.transform_values(&:sum)
|
38
|
+
|
39
|
+
Periodic.report_gauge_by_queue(:queue_age_total, age_total_by_queue)
|
40
|
+
Periodic.report_gauge_by_queue(:queue_age_max, age_max_by_queue)
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.queued_jobs_scope
|
44
44
|
Delayed::Job
|
45
45
|
.current
|
46
46
|
.where("locked_at IS NULL OR locked_by = 'on_hold'") # not running
|
47
|
+
.group(:queue)
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|
@@ -20,19 +20,21 @@ module InstJobsStatsd
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.report_run_depth
|
23
|
-
|
24
|
-
Periodic.report_gauge(:run_depth, scope.count)
|
23
|
+
Periodic.report_gauge_by_queue(:run_depth, running_jobs_scope.count)
|
25
24
|
end
|
26
25
|
|
27
26
|
def self.report_run_age
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
jobs_run_at_by_queue = running_jobs_scope.limit(10_000).pluck(:queue, "ARRAY_AGG(run_at)").to_h
|
28
|
+
age_secs_by_queue = jobs_run_at_by_queue.transform_values { |v| v.map { |t| Delayed::Job.db_time_now - t } }
|
29
|
+
age_max_by_queue = age_secs_by_queue.transform_values(&:max)
|
30
|
+
age_total_by_queue = age_secs_by_queue.transform_values(&:sum)
|
31
|
+
|
32
|
+
Periodic.report_gauge_by_queue(:run_age_total, age_total_by_queue)
|
33
|
+
Periodic.report_gauge_by_queue(:run_age_max, age_max_by_queue)
|
32
34
|
end
|
33
35
|
|
34
36
|
def self.running_jobs_scope
|
35
|
-
Delayed::Job.running
|
37
|
+
Delayed::Job.running.group(:queue)
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -13,9 +13,21 @@ module InstJobsStatsd
|
|
13
13
|
@instance.add(proc)
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.report_gauge(stat, value, job: nil, sample_rate: 1)
|
16
|
+
def self.report_gauge(stat, value, job: nil, sample_rate: 1, additional_tags: {})
|
17
17
|
stats = Naming.qualified_names(stat, job)
|
18
|
-
InstStatsd::Statsd.gauge(stats,
|
18
|
+
InstStatsd::Statsd.gauge(stats,
|
19
|
+
value,
|
20
|
+
sample_rate,
|
21
|
+
short_stat: stat,
|
22
|
+
tags: Naming.dd_job_tags(job).merge(additional_tags))
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.report_gauge_by_queue(stat, value_by_queue)
|
26
|
+
value_by_queue.each do |queue, count|
|
27
|
+
report_gauge(stat, count, additional_tags: { queue: queue })
|
28
|
+
end
|
29
|
+
|
30
|
+
report_gauge("#{stat}.total", value_by_queue.values.sum)
|
19
31
|
end
|
20
32
|
|
21
33
|
class Callbacks
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inst-jobs-statsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Slade
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inst-jobs
|
@@ -268,7 +268,7 @@ dependencies:
|
|
268
268
|
- - "~>"
|
269
269
|
- !ruby/object:Gem::Version
|
270
270
|
version: 1.4.0
|
271
|
-
description:
|
271
|
+
description:
|
272
272
|
email:
|
273
273
|
- jslade@instructure.com
|
274
274
|
executables: []
|
@@ -298,7 +298,7 @@ licenses:
|
|
298
298
|
- MIT
|
299
299
|
metadata:
|
300
300
|
rubygems_mfa_required: 'true'
|
301
|
-
post_install_message:
|
301
|
+
post_install_message:
|
302
302
|
rdoc_options: []
|
303
303
|
require_paths:
|
304
304
|
- lib
|
@@ -313,8 +313,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
313
313
|
- !ruby/object:Gem::Version
|
314
314
|
version: '0'
|
315
315
|
requirements: []
|
316
|
-
rubygems_version: 3.
|
317
|
-
signing_key:
|
316
|
+
rubygems_version: 3.1.6
|
317
|
+
signing_key:
|
318
318
|
specification_version: 4
|
319
319
|
summary: Stats reporting for inst-jobs
|
320
320
|
test_files: []
|