yabeda-activejob 0.3.1 → 0.4.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: 3cd5ae2317f42f9d4e2a5b44bba2d44b792e07f9e55a7992af2e37dabbd6333f
4
- data.tar.gz: 4da6bb136cb5a1ab33a7f3927b79f4a9a50a1188e32340d459ebdcfbf9ca2ca6
3
+ metadata.gz: 3da58bbe370af6fa52cd9021520491f692d4310ea5dcd93d27b0f78eaf5c940b
4
+ data.tar.gz: b3a955f99cfe4482a9cd1da53720967ee508e3b62bbe430a16eaf46e583e00d1
5
5
  SHA512:
6
- metadata.gz: 2f73db31ff848abc54d5e43fb664cb28c5de70b7a5697a349d952bdf1a7e2e605eb8ebdb98edb31c90f0c8832c59162e29d278ae6846c73d0829be4a20ea3a54
7
- data.tar.gz: 5c86775ae9e1811f2fd2e1e9558eeb9fb681635af322180e2d3828d3f7ab2be235b6ea579fb5f13c95324b32fe0e2a14fefa9d5240daffe018b4a3e910f5cea2
6
+ metadata.gz: 9264ea6fc38f7c9aa81543e17dca965a4a68e141bddfaa578e51859a8177d70e1cee195f088f0f9964a70077411f1717478489581a1f2b3b4124d16a893d1b40
7
+ data.tar.gz: c7b404f2a8a05c024df6c81d6720dccfaa6a55ba64fcc9e73ada1035720a29fa2903d1e39ff6377f5a73e89b469781c8a5d6a54fed5d91b5b54be7c9a280b82f
data/README.md CHANGED
@@ -50,6 +50,21 @@ Prometheus::Client.config.data_store = Prometheus::Client::DataStores::DirectFil
50
50
 
51
51
  **Note** if using direct file datastore it must be called before registering any metrics.
52
52
 
53
+ If using `resque` with prometheus and scraping your resque process via the `/metrics` endpoint is unfeasible consider setting up a
54
+ push gateway. Once set up, you can use the `after_event_block` to push metrics to your push gateway after every event is
55
+ complete.
56
+
57
+ ````ruby
58
+ Yabeda.configure do
59
+ Yabeda::ActiveJob.after_event_block = Proc.new do |event|
60
+ # do your pushing or any custom code here
61
+ end
62
+ Yabeda::ActiveJob.install!
63
+ end
64
+ ````
65
+
66
+ **Note**: Since the notifications are registered on install make sure to setup your after_event_block before calling install!
67
+
53
68
  ## Metrics
54
69
 
55
70
  - Total enqueued jobs: `activejob.enqueued_total` segmented by: queue, activejob(job class name), executions(number of executions)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module ActiveJob
5
- VERSION = "0.3.1"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "yabeda"
4
4
  require "yabeda/activejob/version"
5
+ require "active_support"
5
6
 
6
7
  module Yabeda
7
8
  # Small set of metrics on activejob jobs
@@ -11,6 +12,8 @@ module Yabeda
11
12
  30, 60, 120, 300, 1800, 3600, 21_600, # In cases jobs are very long-running
12
13
  ].freeze
13
14
 
15
+ mattr_accessor :after_event_block, default: proc { |_event| }
16
+
14
17
  # rubocop: disable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize
15
18
  def self.install!
16
19
  Yabeda.configure do
@@ -53,6 +56,7 @@ module Yabeda
53
56
 
54
57
  activejob_executed_total.increment(labels)
55
58
  activejob_runtime.measure(labels, Yabeda::ActiveJob.ms2s(event.duration))
59
+ Yabeda::ActiveJob.after_event_block.call(event) if Yabeda::ActiveJob.after_event_block.respond_to?(:call)
56
60
  end
57
61
 
58
62
  # start job event
@@ -68,6 +72,7 @@ module Yabeda
68
72
  labels.merge!(event.payload.slice(*Yabeda.default_tags.keys - labels.keys))
69
73
  job_latency = Yabeda::ActiveJob.job_latency(event)
70
74
  activejob_latency.measure(labels, job_latency) if job_latency.present?
75
+ Yabeda::ActiveJob.after_event_block.call(event) if Yabeda::ActiveJob.after_event_block.respond_to?(:call)
71
76
  end
72
77
 
73
78
  ActiveSupport::Notifications.subscribe "enqueue.active_job" do |*args|
@@ -81,6 +86,7 @@ module Yabeda
81
86
 
82
87
  labels.merge!(event.payload.slice(*Yabeda.default_tags.keys - labels.keys))
83
88
  activejob_enqueued_total.increment(labels)
89
+ Yabeda::ActiveJob.after_event_block.call(event) if Yabeda::ActiveJob.after_event_block.respond_to?(:call)
84
90
  end
85
91
  end
86
92
  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.3.1
4
+ version: 0.4.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-29 00:00:00.000000000 Z
11
+ date: 2022-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails