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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75adb58471b09079b2c7137a9e6d245ca34a87f5943bddbcca8488aa8a7fed21
4
- data.tar.gz: 4eaff38047f48d812c9ec216520d1d180e04ee0a1c28fed56a74af3dff1cb31d
3
+ metadata.gz: 9b5abdf29dc1f2bea57820def73dbfe9ecb2eabdcff95a863e13c463fa332794
4
+ data.tar.gz: d2341ad286ddd4a66f29eafadfacf0d30bb83c844b685f1bd09a7fe302eb33e9
5
5
  SHA512:
6
- metadata.gz: 722e179fb2e42ea0724f83fa58e4f078419ea6b213570ba651abbde64f79516999fd8de3b10c8ff6adb79191bacaf5d4a7b17c1aef360ce400be5ecae8ba5703
7
- data.tar.gz: 1b53949b9e40c84df03d36065be01efa4b321b9f9e261f9dd3b4b774a0cfd1cdd53ede740fb2a1b2b06537991f1cb9c1350cee8bf2723ecc9b2ff3ada67774bd
6
+ metadata.gz: 485073cf7a4925fc68cfce465507ec6890ed2b15edf69ca919ac0044b6013b4e872380252d83dfbdb0c1f743d71f60a8ce81c84811676c03709316759023f8af
7
+ data.tar.gz: ab25a166ad4c2474e704554f1dbec5d8b8e90a325d99b751a118c6041f876ee60139d75e80c8a797b3022aa46963978d34e9caa5376d9ef42cf228c267a35ff4
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.job_executed_total`
32
- - Total successful jobs processed: `activejob.job_success_total`
33
- - Total failed jobs processed: `activejob.job_failed_total`
34
- - Job runtime: `activejob.job_runtime` (in seconds)
35
- - Job latency: `activejob.job_latency` (in seconds)
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).
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module ActiveJob
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -16,22 +16,22 @@ module Yabeda
16
16
  Yabeda.configure do
17
17
  group :activejob
18
18
 
19
- counter :job_executed_total, tags: %i[queue activejob executions],
20
- comment: "A counter of the total number of activejobs executed."
21
- counter :job_success_total, tags: %i[queue activejob executions],
22
- comment: "A counter of the total number of activejobs successfully processed."
23
- counter :job_failed_total, tags: %i[queue activejob executions failure_reason],
24
- comment: "A counter of the total number of jobs failed for an activejob."
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 :job_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
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 :job_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
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
- activejob_job_failed_total.increment(
48
- labels.merge(failure_reason: event.payload[:exception].join(",")),
47
+ activejob_failed_total.increment(
48
+ labels.merge(failure_reason: event.payload[:exception].first.to_s),
49
49
  )
50
50
  else
51
- activejob_job_success_total.increment(labels)
51
+ activejob_success_total.increment(labels)
52
52
  end
53
53
 
54
- activejob_job_executed_total.increment(labels)
55
- activejob_job_runtime.measure(labels, Yabeda::ActiveJob.ms2s(event.duration))
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
- activejob_job_latency.measure(labels, Yabeda::ActiveJob.job_latency(event))
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.1.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