cronitor 5.2.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 256202e94ab78e773be9c52bfd101ba23fb12d33140be4035e03488918db4a09
4
- data.tar.gz: 285d0414d43c71968b11b57be219bd8a8bc5f31b49a66b254124677efcc42869
3
+ metadata.gz: 2db87030650711fcc3d7c2cd27bc3621b5c4d236ed7b56e5ef5cd1e741b552ba
4
+ data.tar.gz: 1b842d3a3afacbdb7a4616678104f0733e4dba902615c5e3db347a1e152b4bb6
5
5
  SHA512:
6
- metadata.gz: bc5ffa239b51b869fc73b11fd83900340823e63fe46a82609a96e2c45f13148c1b6514844e1315a7a584927400a5cbb85381c7fa995940d938bfc1528403e7d3
7
- data.tar.gz: 4666eea5d6f1cf5631fb9fcccadfa6e11d074a560af1a7a411b6dd8f7720dd8667576752337216ee4bca9c2a2dd6e718ecbc14d0b1656b6a6be642657b9fca51
6
+ metadata.gz: 1a8c6c3f4dac4a77d3833e4886eabe94f5e35da907647fdc06dfe0f60648fd234e4597417f4bbfb74d97da176f9cb6f8482b52ac2eb23c43efa7f49420ebea6d
7
+ data.tar.gz: 91a365a74dceada5417865aa7d577ebc40cc12c22549d37d067c288a25507fb4b1df233f66772822b724ff1eddba73098e91d6a03ee5a7597e8edcb1e89d86c6
@@ -39,6 +39,8 @@ jobs:
39
39
  - '3.0'
40
40
  - '3.1'
41
41
  - '3.2'
42
+ - '3.3'
43
+ - '3.4'
42
44
 
43
45
  runs-on: ubuntu-latest
44
46
 
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
- ### Using a YAML configuration file
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
 
@@ -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, :auto_discover_sidekiq, :telemetry_domain
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)
@@ -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 = "https://cronitor.io/api/monitors"
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 self.delete(key)
80
+ def delete
81
81
  resp = HTTParty.delete(
82
- "#{Cronitor.monitor_api_url}/#{key}",
82
+ "#{monitor_api_url}/#{key}",
83
83
  timeout: Cronitor.timeout,
84
84
  basic_auth: {
85
- username: Cronitor.api_key,
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
- "https://cronitor.io/api/monitors"
190
+ MONITOR_API_URL
191
191
  end
192
192
 
193
-
194
193
  private
195
194
 
196
195
  def fetch
@@ -219,7 +218,7 @@ module Cronitor
219
218
  message: params.fetch(:message, nil),
220
219
  series: params.fetch(:series, nil),
221
220
  host: params.fetch(:host, Socket.gethostname),
222
- metric: params[:metrics] ? params[:metrics].map { |k, v| "#{k}:#{v}" } : nil,
221
+ metric: params[:metrics]&.map { |k, v| "#{k}:#{v}" },
223
222
  stamp: Time.now.to_f,
224
223
  env: params.fetch(:env, env)
225
224
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cronitor
4
- VERSION = '5.2.1'
4
+ VERSION = '5.2.2'
5
5
  end
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 < 30 ? 30 : 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.1
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: 2025-01-15 00:00:00.000000000 Z
12
+ date: 2025-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty