yabeda-activejob 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -5
- data/lib/yabeda/activejob/version.rb +1 -1
- data/lib/yabeda/activejob.rb +37 -27
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08158815f9482115a22e494dd4f3b65fd296adb566f1b641f3fa39b15d232bcd'
|
4
|
+
data.tar.gz: 5d57d4ee2d12c75453f852422d044728cff9d7631928f04a76886d321b425bd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea6312266b05349917950bae645a413a257e3ed970ec4b9a5b82d0a177487a6dea3529a144849e489bd37c4aff4ea21a53058d4857226b3f154816c7e551f069
|
7
|
+
data.tar.gz: 7e60c91f4613c747e8572ddbebbad53c7c42613845e3dadb7d3df3b89486ebd332fa9f90bf993d2da4a72b87f917f4ffa4ca98397cdb03f3dac0eb65e4eb8ea2
|
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
# Yabeda::ActiveJob
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/yabeda-activejob.svg)](https://badge.fury.io/rb/yabeda-activejob)
|
3
|
+
![Tests](https://github.com/Fullscript/yabeda-activejob/actions/workflows/test.yml/badge.svg)
|
4
|
+
![Rubocop](https://github.com/Fullscript/yabeda-activejob/actions/workflows/lint.yml/badge.svg)
|
5
|
+
|
2
6
|
Yabeda metrics around rails activejobs. The motivation came from wanting something similar to [yabeda-sidekiq](https://github.com/yabeda-rb/yabeda-sidekiq) for
|
3
7
|
resque but decided to generalize even more with just doing it on the activejob level since that is likely more in use
|
4
8
|
than just resque. and could implement a lot of the general metrics needed without having to leverage your used adapters
|
@@ -28,11 +32,11 @@ you can do the following:
|
|
28
32
|
|
29
33
|
## Metrics
|
30
34
|
|
31
|
-
- Total jobs processed: `activejob.
|
32
|
-
- Total successful jobs processed: `activejob.
|
33
|
-
- Total failed jobs processed: `activejob.
|
34
|
-
- Job runtime: `activejob.
|
35
|
-
- Job latency: `activejob.
|
35
|
+
- Total jobs processed: `activejob.executed_total`
|
36
|
+
- Total successful jobs processed: `activejob.success_total`
|
37
|
+
- Total failed jobs processed: `activejob.failed_total`
|
38
|
+
- Job runtime: `activejob.runtime` (in seconds)
|
39
|
+
- Job latency: `activejob.latency` (in seconds)
|
36
40
|
|
37
41
|
## License
|
38
42
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/yabeda/activejob.rb
CHANGED
@@ -16,27 +16,27 @@ module Yabeda
|
|
16
16
|
Yabeda.configure do
|
17
17
|
group :activejob
|
18
18
|
|
19
|
-
counter :
|
20
|
-
|
21
|
-
counter :
|
22
|
-
|
23
|
-
counter :
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
counter :executed_total, tags: %i[queue activejob executions],
|
20
|
+
comment: "A counter of the total number of activejobs executed."
|
21
|
+
counter :enqueued_total, tags: %i[queue activejob executions],
|
22
|
+
comment: "A counter of the total number of activejobs enqueued."
|
23
|
+
counter :success_total, tags: %i[queue activejob executions],
|
24
|
+
comment: "A counter of the total number of activejobs successfully processed."
|
25
|
+
counter :failed_total, tags: %i[queue activejob executions failure_reason],
|
26
|
+
comment: "A counter of the total number of jobs failed for an activejob."
|
27
|
+
|
28
|
+
histogram :runtime, comment: "A histogram of the activejob execution time.",
|
29
|
+
unit: :seconds, per: :activejob,
|
30
|
+
tags: %i[queue activejob executions],
|
31
|
+
buckets: LONG_RUNNING_JOB_RUNTIME_BUCKETS
|
32
|
+
|
33
|
+
histogram :latency, comment: "The job latency, the difference in seconds between enqueued and running time",
|
34
|
+
unit: :seconds, per: :activejob,
|
35
|
+
tags: %i[queue activejob executions],
|
36
|
+
buckets: LONG_RUNNING_JOB_RUNTIME_BUCKETS
|
35
37
|
|
36
38
|
# job complete event
|
37
39
|
ActiveSupport::Notifications.subscribe "perform.active_job" do |*args|
|
38
|
-
::Rails.logger.debug("JOB COMPLETE")
|
39
|
-
|
40
40
|
event = ActiveSupport::Notifications::Event.new(*args)
|
41
41
|
labels = {
|
42
42
|
activejob: event.payload[:job].class.to_s,
|
@@ -44,32 +44,42 @@ module Yabeda
|
|
44
44
|
executions: event.payload[:job].instance_variable_get(:@executions).to_s,
|
45
45
|
}
|
46
46
|
if event.payload[:exception].present?
|
47
|
-
|
48
|
-
labels.merge(failure_reason: event.payload[:exception].
|
47
|
+
activejob_failed_total.increment(
|
48
|
+
labels.merge(failure_reason: event.payload[:exception].first.to_s),
|
49
49
|
)
|
50
50
|
else
|
51
|
-
|
51
|
+
activejob_success_total.increment(labels)
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
54
|
+
activejob_executed_total.increment(labels)
|
55
|
+
activejob_runtime.measure(labels, Yabeda::ActiveJob.ms2s(event.duration))
|
56
56
|
end
|
57
57
|
|
58
58
|
# start job event
|
59
59
|
ActiveSupport::Notifications.subscribe "perform_start.active_job" do |*args|
|
60
60
|
event = ActiveSupport::Notifications::Event.new(*args)
|
61
|
-
::Rails.logger.debug("JOB START")
|
62
|
-
puts "JOB START"
|
63
61
|
|
64
62
|
labels = {
|
65
63
|
activejob: event.payload[:job].class.to_s,
|
66
64
|
queue: event.payload[:job].instance_variable_get(:@queue_name),
|
67
65
|
executions: event.payload[:job].instance_variable_get(:@executions).to_s,
|
68
66
|
}
|
69
|
-
::Rails.logger.info(labels.inspect)
|
70
67
|
|
71
68
|
labels.merge!(event.payload.slice(*Yabeda.default_tags.keys - labels.keys))
|
72
|
-
|
69
|
+
activejob_latency.measure(labels, Yabeda::ActiveJob.job_latency(event))
|
70
|
+
end
|
71
|
+
|
72
|
+
ActiveSupport::Notifications.subscribe "enqueue.active_job" do |*args|
|
73
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
74
|
+
|
75
|
+
labels = {
|
76
|
+
activejob: event.payload[:job].class.to_s,
|
77
|
+
queue: event.payload[:job].instance_variable_get(:@queue_name),
|
78
|
+
executions: event.payload[:job].instance_variable_get(:@executions).to_s,
|
79
|
+
}
|
80
|
+
|
81
|
+
labels.merge!(event.payload.slice(*Yabeda.default_tags.keys - labels.keys))
|
82
|
+
activejob_enqueued_total.increment(labels)
|
73
83
|
end
|
74
84
|
end
|
75
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yabeda-activejob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fullscript
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '6.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.21'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.21'
|
97
111
|
description: Prometheus exporter for collecting metrics around your activejobs
|
98
112
|
email:
|
99
113
|
- josh.etsenake@fullscript.com
|