yabeda-activejob 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +9 -5
- data/lib/yabeda/activejob/version.rb +1 -1
- data/lib/yabeda/activejob.rb +20 -21
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b5abdf29dc1f2bea57820def73dbfe9ecb2eabdcff95a863e13c463fa332794
|
4
|
+
data.tar.gz: d2341ad286ddd4a66f29eafadfacf0d30bb83c844b685f1bd09a7fe302eb33e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 485073cf7a4925fc68cfce465507ec6890ed2b15edf69ca919ac0044b6013b4e872380252d83dfbdb0c1f743d71f60a8ce81c84811676c03709316759023f8af
|
7
|
+
data.tar.gz: ab25a166ad4c2474e704554f1dbec5d8b8e90a325d99b751a118c6041f876ee60139d75e80c8a797b3022aa46963978d34e9caa5376d9ef42cf228c267a35ff4
|
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
# Yabeda::ActiveJob
|
2
|
+
[](https://badge.fury.io/rb/yabeda-activejob)
|
3
|
+

|
4
|
+

|
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,22 +16,22 @@ module Yabeda
|
|
16
16
|
Yabeda.configure do
|
17
17
|
group :activejob
|
18
18
|
|
19
|
-
counter :
|
20
|
-
|
21
|
-
counter :
|
22
|
-
|
23
|
-
counter :
|
24
|
-
|
19
|
+
counter :executed_total, tags: %i[queue activejob executions],
|
20
|
+
comment: "A counter of the total number of activejobs executed."
|
21
|
+
counter :success_total, tags: %i[queue activejob executions],
|
22
|
+
comment: "A counter of the total number of activejobs successfully processed."
|
23
|
+
counter :failed_total, tags: %i[queue activejob executions failure_reason],
|
24
|
+
comment: "A counter of the total number of jobs failed for an activejob."
|
25
25
|
|
26
|
-
histogram :
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
histogram :runtime, comment: "A histogram of the activejob execution time.",
|
27
|
+
unit: :seconds, per: :activejob,
|
28
|
+
tags: %i[queue activejob executions],
|
29
|
+
buckets: LONG_RUNNING_JOB_RUNTIME_BUCKETS
|
30
30
|
|
31
|
-
histogram :
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
histogram :latency, comment: "The job latency, the difference in seconds between enqueued and running time",
|
32
|
+
unit: :seconds, per: :activejob,
|
33
|
+
tags: %i[queue activejob executions],
|
34
|
+
buckets: LONG_RUNNING_JOB_RUNTIME_BUCKETS
|
35
35
|
|
36
36
|
# job complete event
|
37
37
|
ActiveSupport::Notifications.subscribe "perform.active_job" do |*args|
|
@@ -44,22 +44,21 @@ 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
61
|
::Rails.logger.debug("JOB START")
|
62
|
-
puts "JOB START"
|
63
62
|
|
64
63
|
labels = {
|
65
64
|
activejob: event.payload[:job].class.to_s,
|
@@ -69,7 +68,7 @@ module Yabeda
|
|
69
68
|
::Rails.logger.info(labels.inspect)
|
70
69
|
|
71
70
|
labels.merge!(event.payload.slice(*Yabeda.default_tags.keys - labels.keys))
|
72
|
-
|
71
|
+
activejob_latency.measure(labels, Yabeda::ActiveJob.job_latency(event))
|
73
72
|
end
|
74
73
|
end
|
75
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yabeda-activejob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fullscript
|
@@ -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
|