sidekiq-cronitor 3.6.0 → 3.7.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: d6373d1623a7c00d0e260437399f5ec1574db09700d9e212e1a51960a5efdbca
4
- data.tar.gz: 6843e645b9cbd23edf564d8b95af27d8a7deea2247bb451b08ed862d018e0e63
3
+ metadata.gz: 58670e7c63fcd04abfa27f9e5e0e0ad717e3a630eb8e5d00f8ba8420eec6e5e2
4
+ data.tar.gz: 859ef82c42ff3053ff10d5a1d20a8f8d35e471326ebcc067a6eed6a02832d856
5
5
  SHA512:
6
- metadata.gz: c45f495adaa7f83d80db7da49c7ae8d89b6999a6259653543de2a57dd543751f09f8c6d5ec2002df143db86ebad3732d3d60c2ea85a7739be2205fff6ec9c2e1
7
- data.tar.gz: 2dd6b470ee157a2ee44a7207138623e5b43e39a3f7d7454aa6c0d8dcfa89cd4741d80b4aecad8d04e7586f5ae573775992d67afb70e5fa4dd5a0fa7e044adaec
6
+ metadata.gz: a7f3979bea1da06b7e8f30de736485f26867d4c10ebcf456e8c0e376764d689e77d00e7b7672830fa79abfec163fd9f27405d13100601bc0717d2b3bc13f38c1
7
+ data.tar.gz: e6b23c396b7e27c0ad88bf12125b7da3c813b22c720df44e9c28ea173a89d435c633245f4b40e362b5a3419c521832ba063b65f7688686e59f21a3a9704c31c2
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # Sidekiq Cronitor
2
2
 
3
- [Cronitor](https://cronitor.io/) provides dead simple monitoring for cron jobs, daemons, queue workers, websites, APIs, and anything else that can send or receive an HTTP request. The Cronitor Sidekiq library provides a drop in integration for monitoring any Sidekiq Job.
4
-
3
+ ![Tests](https://github.com/cronitorio/cronitor-sidekiq/workflows/Tests/badge.svg)
5
4
 
6
- #### NOTE: Version 3.0.0 changes the integration method from 2.x.x - you now add middleware in the Sidekiq initializer. This significantly reduces the integration overhead, however it is a BREAKING CHANGE. Existing users who would like to migrate to version 3.x.x should [contact support](mailto:support@cronitor.io) for assistance with the migration.
5
+ [Cronitor](https://cronitor.io/) provides dead simple monitoring for cron jobs, daemons, queue workers, websites, APIs, and anything else that can send or receive an HTTP request. The Cronitor Sidekiq library provides a drop in integration for monitoring any Sidekiq Job.
7
6
 
8
7
  ## Installation
9
8
 
@@ -16,7 +15,7 @@ gem 'sidekiq-cronitor'
16
15
 
17
16
  And then bundle:
18
17
 
19
- ```
18
+ ```sh
20
19
  bundle
21
20
  ```
22
21
 
@@ -39,7 +38,6 @@ Cronitor.api_key = 'api_key_123'
39
38
  Cronitor.environment = 'development' #default: 'production'
40
39
  ```
41
40
 
42
-
43
41
  Monitor jobs by registering `Sidekiq::Cronitor::ServerMiddleware` server [middleware](https://www.rubydoc.info/github/mperham/sidekiq/Sidekiq/Middleware) (most people do this in the Sidekiq initializer).
44
42
 
45
43
  ```ruby
@@ -50,7 +48,6 @@ Sidekiq.configure_server do |config|
50
48
  end
51
49
  ```
52
50
 
53
-
54
51
  Once the server middleware is registered, Cronitor will send [telemetry events](https://cronitor.io/docs/teleme) 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
52
 
56
53
  Optional: You can specify the monitor key directly using `sidekiq_options`:
@@ -65,6 +62,8 @@ class MyJob
65
62
  end
66
63
  ```
67
64
 
65
+ ### Enable/Disable
66
+
68
67
  To disable Cronitor for a specific job you can set the following option:
69
68
 
70
69
  ```ruby
@@ -77,7 +76,33 @@ class MyJob
77
76
  end
78
77
  ```
79
78
 
79
+ To disable Cronitor for all jobs, and selectively enable it, you can set the following option:
80
+
81
+ ```sh
82
+ export CRONITOR_AUTO_DISCOVER_SIDEKIQ='false'
83
+ ```
84
+
85
+ or
86
+
87
+ ```ruby
88
+ require 'cronitor'
89
+ Cronitor.auto_discover_sidekiq = false
90
+ ```
91
+
92
+ then enable the jobs you want to report to Cronitor:
93
+
94
+ ```ruby
95
+ class MyJob
96
+ include Sidekiq::Job
97
+ sidekiq_options cronitor_enabled: true
98
+
99
+ def perform
100
+ end
101
+ end
102
+ ```
103
+
80
104
  ## Periodic/Scheduled Jobs
105
+
81
106
  If you are using Sidekiq Enterprise to run [Periodic Jobs](https://github.com/mperham/sidekiq/wiki/Ent-Periodic-Jobs) or are using the popular [sidekiq-scheduler](https://github.com/moove-it/sidekiq-scheduler) gem, you can sync the schedules of those jobs with a single command.
82
107
 
83
108
  ```ruby
@@ -86,7 +111,6 @@ Sidekiq::Cronitor::PeriodicJobs.sync_schedule!
86
111
  Sidekiq::Cronitor::SidekiqScheduler.sync_schedule!
87
112
  ```
88
113
 
89
-
90
114
  ## Development
91
115
 
92
116
  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.
@@ -95,7 +119,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
95
119
 
96
120
  ## Contributing
97
121
 
98
- Bug reports and pull requests are welcome on GitHub at https://github.com/cronitorio/cronitor-sidekiq/pulls. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
122
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/cronitorio/cronitor-sidekiq/pulls>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
99
123
 
100
124
  ## License
101
125
 
@@ -6,7 +6,11 @@ module Sidekiq::Cronitor
6
6
  monitors_payload = []
7
7
  loops = Sidekiq::Periodic::LoopSet.new
8
8
  loops.each do |lop|
9
- next if fetch_option(lop, 'cronitor_disabled')
9
+ if fetch_option(lop, 'cronitor_enabled')
10
+ next unless fetch_option(lop, 'cronitor_enabled', Cronitor.auto_discover_sidekiq)
11
+ else
12
+ next if fetch_option(lop, 'cronitor_disabled', !Cronitor.auto_discover_sidekiq)
13
+ end
10
14
 
11
15
  monitors_payload << {
12
16
  key: fetch_option(lop, 'cronitor_key') || lop.klass.to_s,
@@ -25,9 +29,9 @@ module Sidekiq::Cronitor
25
29
  Sidekiq.logger.error("[cronitor] error during #{name}.#{__method__}: #{e}")
26
30
  end
27
31
 
28
- def self.fetch_option(lop, key)
29
- lop.options.fetch(key, nil) ||
30
- lop.klass.constantize.sidekiq_options.fetch(key, nil)
32
+ def self.fetch_option(lop, key, default = nil)
33
+ lop.options.fetch(key, default) ||
34
+ lop.klass.constantize.sidekiq_options.fetch(key, default)
31
35
  end
32
36
  end
33
37
  end
@@ -12,7 +12,12 @@ module Sidekiq::Cronitor
12
12
  # just in case an explicit job key has been set
13
13
  job_klass = Object.const_get(v['class'])
14
14
  job_key = job_klass.sidekiq_options.fetch('cronitor_key', v['class'])
15
- next if job_klass.sidekiq_options.fetch('cronitor_disabled', false)
15
+
16
+ if job_klass.sidekiq_options['cronitor_enabled']
17
+ next unless job_klass.sidekiq_options.fetch('cronitor_enabled', Cronitor.auto_discover_sidekiq)
18
+ else
19
+ next if job_klass.sidekiq_options.fetch('cronitor_disabled', !Cronitor.auto_discover_sidekiq)
20
+ end
16
21
 
17
22
  monitors_payload << { key: job_key.to_s, schedule: schedule, platform: 'sidekiq', type: 'job' }
18
23
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Cronitor
3
- VERSION = '3.6.0'
3
+ VERSION = '3.7.0'
4
4
  end
5
5
  end
@@ -27,16 +27,16 @@ module Sidekiq::Cronitor
27
27
  end
28
28
 
29
29
  private
30
+
30
31
  def cronitor(worker)
31
32
  Cronitor::Monitor.new(job_key(worker))
32
33
  end
33
34
 
34
35
  def cronitor_disabled?(worker)
35
- disabled = worker.class.sidekiq_options.fetch("cronitor_disabled", nil)
36
- if disabled.nil?
37
- options(worker).fetch(:disabled, false)
36
+ if worker.class.sidekiq_options["cronitor_enabled"]
37
+ !worker.class.sidekiq_options.fetch("cronitor_enabled", Cronitor.auto_discover_sidekiq)
38
38
  else
39
- !!disabled
39
+ worker.class.sidekiq_options.fetch("cronitor_disabled", options(worker).fetch(:disabled, !Cronitor.auto_discover_sidekiq))
40
40
  end
41
41
  end
42
42
 
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.6.0
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeke Gabrielse
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2023-02-01 00:00:00.000000000 Z
14
+ date: 2023-03-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sidekiq
@@ -33,14 +33,14 @@ dependencies:
33
33
  requirements:
34
34
  - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: '5.0'
36
+ version: '5.1'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '5.0'
43
+ version: '5.1'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: bundler
46
46
  requirement: !ruby/object:Gem::Requirement