cronitor 5.2.0 → 5.2.2
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 +4 -4
- data/.github/workflows/test.yml +2 -0
- data/README.md +3 -1
- data/lib/cronitor/config.rb +2 -2
- data/lib/cronitor/monitor.rb +17 -9
- data/lib/cronitor/version.rb +1 -1
- data/lib/cronitor.rb +1 -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: 2db87030650711fcc3d7c2cd27bc3621b5c4d236ed7b56e5ef5cd1e741b552ba
|
4
|
+
data.tar.gz: 1b842d3a3afacbdb7a4616678104f0733e4dba902615c5e3db347a1e152b4bb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a8c6c3f4dac4a77d3833e4886eabe94f5e35da907647fdc06dfe0f60648fd234e4597417f4bbfb74d97da176f9cb6f8482b52ac2eb23c43efa7f49420ebea6d
|
7
|
+
data.tar.gz: 91a365a74dceada5417865aa7d577ebc40cc12c22549d37d067c288a25507fb4b1df233f66772822b724ff1eddba73098e91d6a03ee5a7597e8edcb1e89d86c6
|
data/.github/workflows/test.yml
CHANGED
data/README.md
CHANGED
@@ -62,7 +62,7 @@ monitor.ping(state: 'complete', metrics: {count: 1000, error_count: 17})
|
|
62
62
|
|
63
63
|
## Configuring Monitors
|
64
64
|
|
65
|
-
###
|
65
|
+
### YAML Configuration File
|
66
66
|
|
67
67
|
You can configure all of your monitors using a single YAML file. This can be version controlled and synced to Cronitor as part of
|
68
68
|
a deployment or build process. For details on all of the attributes that can be set, see the [Monitor API](https://cronitor.io/docs/monitor-api) documentation.
|
@@ -128,6 +128,8 @@ heartbeats:
|
|
128
128
|
events: true # send alert when the event occurs
|
129
129
|
|
130
130
|
```
|
131
|
+
#### Async Uploads
|
132
|
+
If you are working with large YAML files (300+ monitors), you may hit timeouts when trying to sync monitors in a single http request. This workload to be processed asynchronously by adding the key `async: true` to the config file. The request will immediately return a `batch_key`. If a `webhook_url` parameter is included, Cronitor will POST to that URL with the results of the background processing and will include the `batch_key` matching the one returned in the initial response.
|
131
133
|
|
132
134
|
### Using `Cronitor::Monitor.put`
|
133
135
|
|
data/lib/cronitor/config.rb
CHANGED
@@ -9,12 +9,12 @@ module Cronitor
|
|
9
9
|
YAML_KEYS = MONITOR_TYPES.map { |t| "#{t}s" }
|
10
10
|
|
11
11
|
class << self
|
12
|
-
attr_accessor :api_key, :api_version, :environment, :logger, :config, :timeout, :ping_timeout,
|
12
|
+
attr_accessor :api_key, :api_version, :environment, :logger, :config, :timeout, :ping_timeout,
|
13
|
+
:auto_discover_sidekiq, :telemetry_domain
|
13
14
|
|
14
15
|
def configure(&block)
|
15
16
|
block.call(self)
|
16
17
|
end
|
17
|
-
|
18
18
|
end
|
19
19
|
|
20
20
|
self.api_key = ENV.fetch('CRONITOR_API_KEY', nil)
|
data/lib/cronitor/monitor.rb
CHANGED
@@ -5,6 +5,7 @@ module Cronitor
|
|
5
5
|
attr_reader :key, :api_key, :api_version, :env
|
6
6
|
|
7
7
|
PING_RETRY_THRESHOLD = 3
|
8
|
+
MONITOR_API_URL = 'https://cronitor.io/api/monitors'
|
8
9
|
|
9
10
|
module Formats
|
10
11
|
ALL = [
|
@@ -24,13 +25,12 @@ module Cronitor
|
|
24
25
|
})
|
25
26
|
end
|
26
27
|
|
27
|
-
|
28
28
|
def self.put(opts = {})
|
29
29
|
rollback = opts[:rollback] || false
|
30
30
|
opts.delete(:rollback)
|
31
31
|
|
32
32
|
monitors = opts[:monitors] || [opts]
|
33
|
-
url =
|
33
|
+
url = MONITOR_API_URL
|
34
34
|
if opts[:format] == Cronitor::Monitor::Formats::YAML
|
35
35
|
url = "#{url}.yaml"
|
36
36
|
monitors['rollback'] = true if rollback
|
@@ -77,12 +77,12 @@ module Cronitor
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
80
|
+
def delete
|
81
81
|
resp = HTTParty.delete(
|
82
|
-
"#{
|
82
|
+
"#{monitor_api_url}/#{key}",
|
83
83
|
timeout: Cronitor.timeout,
|
84
84
|
basic_auth: {
|
85
|
-
username:
|
85
|
+
username: api_key,
|
86
86
|
password: ''
|
87
87
|
},
|
88
88
|
headers: Cronitor::Monitor::Headers::JSON
|
@@ -187,10 +187,9 @@ module Cronitor
|
|
187
187
|
end
|
188
188
|
|
189
189
|
def monitor_api_url
|
190
|
-
|
190
|
+
MONITOR_API_URL
|
191
191
|
end
|
192
192
|
|
193
|
-
|
194
193
|
private
|
195
194
|
|
196
195
|
def fetch
|
@@ -201,7 +200,16 @@ module Cronitor
|
|
201
200
|
return
|
202
201
|
end
|
203
202
|
|
204
|
-
HTTParty.get(
|
203
|
+
HTTParty.get(
|
204
|
+
monitor_api_url,
|
205
|
+
basic_auth: {
|
206
|
+
username: api_key,
|
207
|
+
password: ''
|
208
|
+
},
|
209
|
+
timeout: Cronitor.timeout,
|
210
|
+
headers: Cronitor::Monitor::Headers::JSON,
|
211
|
+
format: :json
|
212
|
+
)
|
205
213
|
end
|
206
214
|
|
207
215
|
def clean_params(params)
|
@@ -210,7 +218,7 @@ module Cronitor
|
|
210
218
|
message: params.fetch(:message, nil),
|
211
219
|
series: params.fetch(:series, nil),
|
212
220
|
host: params.fetch(:host, Socket.gethostname),
|
213
|
-
metric: params[:metrics]
|
221
|
+
metric: params[:metrics]&.map { |k, v| "#{k}:#{v}" },
|
214
222
|
stamp: Time.now.to_f,
|
215
223
|
env: params.fetch(:env, env)
|
216
224
|
}
|
data/lib/cronitor/version.rb
CHANGED
data/lib/cronitor.rb
CHANGED
@@ -32,7 +32,7 @@ module Cronitor
|
|
32
32
|
def self.apply_config(rollback: false)
|
33
33
|
conf = read_config
|
34
34
|
# allow a significantly longer timeout on requests that are sending full yaml config. min 30 seconds.
|
35
|
-
timeout = Cronitor.timeout
|
35
|
+
timeout = [Cronitor.timeout, 30].max
|
36
36
|
monitors = Monitor.put(monitors: conf, format: Cronitor::Monitor::Formats::YAML, rollback: rollback,
|
37
37
|
timeout: timeout)
|
38
38
|
count = 0
|
@@ -62,7 +62,6 @@ module Cronitor
|
|
62
62
|
raise e
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
66
65
|
end
|
67
66
|
|
68
67
|
Cronitor.read_config(Cronitor.config) unless Cronitor.config.nil?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Byrnes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-09-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|