sidekiq-cronitor 3.0.0 → 3.1.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: cab38f6cd486339c23ce89d495d8fd320536ad475385c77f2f28f08ddc78a47b
4
- data.tar.gz: ecee9682b2caf0b6becfa83354a5be5275c192f57ab09e1c2da2368ce2aa85f1
3
+ metadata.gz: 826cb62a159a1c7f33af2cdabe5f56edfb2debaef6d73f9541f61106a8f77e0a
4
+ data.tar.gz: e459ad13e7723388db7c4448c192edb426de1454a2b22a28ec3441917bc17fdc
5
5
  SHA512:
6
- metadata.gz: fcbd75ca1e900e2a409d281c2fbad43e6fd76e6c03778c2b87df92cf50160573e96fd437a06f5db1b95e6c7e7c53ec9e3af9dfdce486bef9da517b7f08c07a25
7
- data.tar.gz: 9b61ae50868b37b951c444090180ab4b8e0ce680185c61291f6eb16ae71a4138de89cf97d785a330c58948917cc287578526a9b2cb3c78a2b5a2fa779c4b6d8f
6
+ metadata.gz: b3f6e392551e1118f5db63a7057fa61b4aa0efb060fa9eb2b598f8afc6ad5c268e68c614dad8dfbf168b128a2139fae26fc6e5835754826f35dd6ea361c9e50a
7
+ data.tar.gz: 58046cc6213e103480928fb4bcc908a5cdc3b4848881aeba4d54af956690f98081b66bf8e492127205e643a62a9396283dd7d0a6d1cf364698fe04c947b0d731
data/README.md CHANGED
@@ -53,14 +53,12 @@ end
53
53
 
54
54
  When this job is invoked, Cronitor will send telemetry pings with a `key` matching the name of your job class (`MyJob` in the example below). If no monitor exists it will create one on the first event. You can configure rules at a later time via the Cronitor dashboard, API, or [YAML config](https://github.com/cronitorio/cronitor-ruby#configuring-monitors) file.
55
55
 
56
- If you want to specify the Cronitor key directly (not required) you can do so using `sidekiq_options`:
56
+ Optional: You can specify the monitor key directly using `sidekiq_options`:
57
57
 
58
58
  ```ruby
59
59
  class MyJob
60
60
  include Sidekiq::Job
61
-
62
- # note that 'key' should be set with a symbol as the key in the hash
63
- sidekiq_options cronitor: { key: 'abc123' }
61
+ sidekiq_options cronitor_key: 'abc123'
64
62
 
65
63
  def perform
66
64
  end
@@ -72,16 +70,31 @@ To disable Cronitor for a specific job you can set the following option:
72
70
 
73
71
  ```ruby
74
72
  class MyJob
75
- include Sidekiq::MyJob
76
-
77
- # note that 'disabled' should be set with a symbol as the key in the hash
78
- sidekiq_options cronitor: { disabled: true }
73
+ include Sidekiq::Job
74
+ sidekiq_options cronitor_disabled: true
79
75
 
80
76
  def perform
81
77
  end
82
78
  end
83
79
  ```
84
80
 
81
+ ## Disabling For Some Jobs
82
+ If you have an entire group or category of jobs you wish to disable monitoring on, it's easiest to create a base class with that option set and then have all your jobs inherit from that base class.
83
+
84
+ ```ruby
85
+ class UnmonitoredJob
86
+ include Sidekiq::Job
87
+ sidekiq_options cronitor_disabled: true
88
+ end
89
+
90
+ class NoInstrumentationJob < UnmonitoredJob
91
+ def perform
92
+ end
93
+ end
94
+ ```
95
+
96
+ Note: Do NOT set a cronitor_key option on your base class or all your inherited jobs will report under the same job in Cronitor.
97
+
85
98
  ## Development
86
99
 
87
100
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Cronitor
3
- VERSION = '3.0.0'
3
+ VERSION = '3.1.0'
4
4
  end
5
5
  end
@@ -24,15 +24,23 @@ module Sidekiq::Cronitor
24
24
  end
25
25
 
26
26
  def cronitor_disabled?(worker)
27
- options(worker).fetch(:disabled, false)
27
+ disabled = worker.class.sidekiq_options.fetch(:cronitor_disabled, nil)
28
+ if disabled.nil?
29
+ options(worker).fetch(:disabled, false)
30
+ else
31
+ !!disabled
32
+ end
28
33
  end
29
34
 
30
35
  def job_key(worker)
36
+ worker.class.sidekiq_options.fetch(:cronitor_key, nil) ||
31
37
  options(worker).fetch(:key, worker.class.name)
32
38
  end
33
39
 
34
40
  def options(worker)
35
- opts = worker.class.sidekiq_options.fetch('cronitor', {})
41
+ # eventually we will delete this method of passing options
42
+ # ultimately we want all cronitor options to be top level keys
43
+ opts = worker.class.sidekiq_options.fetch(:cronitor, {})
36
44
  # symbolize_keys is a rails helper, so only use it if it's defined
37
45
  opts = opts.symbolize_keys if opts.respond_to?(:symbolize_keys)
38
46
  opts
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-cronitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeke Gabrielse
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-03-08 00:00:00.000000000 Z
12
+ date: 2022-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq