sidekiq-cronitor 3.0.0 → 3.1.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 +21 -8
- data/lib/sidekiq/cronitor/version.rb +1 -1
- data/lib/sidekiq/cronitor.rb +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 826cb62a159a1c7f33af2cdabe5f56edfb2debaef6d73f9541f61106a8f77e0a
|
4
|
+
data.tar.gz: e459ad13e7723388db7c4448c192edb426de1454a2b22a28ec3441917bc17fdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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::
|
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.
|
data/lib/sidekiq/cronitor.rb
CHANGED
@@ -24,15 +24,23 @@ module Sidekiq::Cronitor
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def cronitor_disabled?(worker)
|
27
|
-
|
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
|
-
|
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.
|
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-
|
12
|
+
date: 2022-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sidekiq
|