judoscale-ruby 1.4.1 → 1.5.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: b5ca5d8a39c5ebac4175cf82ee527e731b3d2ca749b54ad39c1fb7901cabbc16
4
- data.tar.gz: 3b33a3243e86bafbbe2f4c492a426ef12c45d46b14a34953e4fd4785a5884c9d
3
+ metadata.gz: a766d2886f2a830ffbb2f0e78ccf6a57340ad6bdc2a4321cba543c0a96eebc1c
4
+ data.tar.gz: 2ef0b540e8bb96756f3f4073f14a17617bf5059cdfc4ce79cc30e32e1ca745c4
5
5
  SHA512:
6
- metadata.gz: 4fcb9704f24d532eda30e5c464428ae52bcdc1d41627da9c1d3408d9a04e099206c74d90c45456c676f33661805fa469cfa250313fbde9fce9fae6a2897ae75e
7
- data.tar.gz: f7a8c075e63febeb03473ddeb4f3c6601916ff4208bfd5d5cf69f90056291d9fea7d2d3b7cc6fbadb6ce0db43958a751f6ad1f7fefd4f596c5ae38b208199567
6
+ metadata.gz: 4d626022cf870df05d6e3c858f8f2099f87b8f4012d6fcc00a5da751a28536cd5b9417154ab2158cfd8107707634be78d681c732c84f42f4fab4a1fc2d78bc1d
7
+ data.tar.gz: dc9a0959de8f65fe02547b7b1334d60bc4e28905b4942a3e6e07f2495059ddc773612f48c72d6d6f59302b73a1b52b8037f4053f4b508b7af5de316ee1970815
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- judoscale-ruby (1.4.1)
4
+ judoscale-ruby (1.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -31,6 +31,7 @@ GEM
31
31
  PLATFORMS
32
32
  arm64-darwin-20
33
33
  arm64-darwin-21
34
+ arm64-darwin-22
34
35
  x86_64-darwin-21
35
36
  x86_64-linux
36
37
 
@@ -5,35 +5,14 @@ require "logger"
5
5
 
6
6
  module Judoscale
7
7
  class Config
8
- class RuntimeContainer
9
- # E.g.:
10
- # (Heroku) => "worker_fast", "3"
11
- # (Render) => "srv-cfa1es5a49987h4vcvfg", "5497f74465-m5wwr", "web" (or "worker", "pserv", "cron", "static")
12
- def initialize(service_name = nil, instance = nil, service_type = nil)
13
- @service_name = service_name
14
- @instance = instance
15
- @service_type = service_type
16
- end
17
-
18
- def to_s
19
- # heroku: 'worker_fast.5'
20
- # render: 'srv-cfa1es5a49987h4vcvfg.5497f74465-m5wwr'
21
- "#{@service_name}.#{@instance}"
22
- end
23
-
24
- def web?
25
- # NOTE: Heroku isolates 'web' as the required _name_ for its web process
26
- # type, Render exposes the actual service type more explicitly
27
- @service_name == "web" || @service_type == "web"
28
- end
29
-
8
+ class RuntimeContainer < String
30
9
  # Since Heroku exposes ordinal dyno 'numbers', we can tell if the current
31
10
  # instance is redundant (and thus skip collecting some metrics sometimes)
32
11
  # We don't have a means of determining that on Render though — so every
33
12
  # instance must be considered non-redundant
34
13
  def redundant_instance?
35
- instance_is_number = Integer(@instance, exception: false)
36
- instance_is_number && instance_is_number != 1
14
+ instance_number = split(".")[1].to_i
15
+ instance_number > 1
37
16
  end
38
17
  end
39
18
 
@@ -106,14 +85,15 @@ module Judoscale
106
85
 
107
86
  if ENV["RENDER_INSTANCE_ID"]
108
87
  instance = ENV["RENDER_INSTANCE_ID"].delete_prefix(ENV["RENDER_SERVICE_ID"]).delete_prefix("-")
109
- @current_runtime_container = RuntimeContainer.new ENV["RENDER_SERVICE_ID"], instance, ENV["RENDER_SERVICE_TYPE"]
88
+ @current_runtime_container = RuntimeContainer.new instance
110
89
  @api_base_url ||= "https://adapter.judoscale.com/api/#{ENV["RENDER_SERVICE_ID"]}"
111
90
  elsif ENV["DYNO"]
112
- service_name, instance = ENV["DYNO"].split "."
113
- @current_runtime_container = RuntimeContainer.new service_name, instance
91
+ @current_runtime_container = RuntimeContainer.new ENV["DYNO"]
92
+ elsif (metadata_uri = ENV["ECS_CONTAINER_METADATA_URI"])
93
+ @current_runtime_container = RuntimeContainer.new(metadata_uri.split("/").last)
114
94
  else
115
95
  # unsupported platform? Don't want to leave @current_runtime_container nil though
116
- @current_runtime_container = RuntimeContainer.new
96
+ @current_runtime_container = RuntimeContainer.new("")
117
97
  end
118
98
  end
119
99
 
@@ -12,6 +12,12 @@ module Judoscale
12
12
  sql
13
13
  end
14
14
 
15
+ def self.table_exists?(table_name)
16
+ ::ActiveRecord::Base.connection.table_exists?(table_name)
17
+ rescue ActiveRecord::NoDatabaseError
18
+ false
19
+ end
20
+
15
21
  private
16
22
 
17
23
  def run_silently(&block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Judoscale
4
- VERSION = "1.4.1"
4
+ VERSION = "1.5.0"
5
5
  end
@@ -5,12 +5,6 @@ require "judoscale/metrics_store"
5
5
 
6
6
  module Judoscale
7
7
  class WebMetricsCollector < MetricsCollector
8
- # NOTE: We collect metrics on all running web processes since they
9
- # all receive and handle requests independently
10
- def self.collect?(config)
11
- config.current_runtime_container.web?
12
- end
13
-
14
8
  def collect
15
9
  MetricsStore.instance.flush
16
10
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judoscale-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam McCrea
8
8
  - Carlos Antonio da Silva
9
9
  - Jon Sullivan
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-05-04 00:00:00.000000000 Z
13
+ date: 2023-07-21 00:00:00.000000000 Z
14
14
  dependencies: []
15
- description:
15
+ description:
16
16
  email:
17
17
  - hello@judoscale.com
18
18
  executables: []
@@ -49,7 +49,7 @@ metadata:
49
49
  documentation_uri: https://judoscale.com/docs
50
50
  changelog_uri: https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md
51
51
  source_code_uri: https://github.com/judoscale/judoscale-ruby
52
- post_install_message:
52
+ post_install_message:
53
53
  rdoc_options: []
54
54
  require_paths:
55
55
  - lib
@@ -64,8 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubygems_version: 3.2.32
68
- signing_key:
67
+ rubygems_version: 3.4.10
68
+ signing_key:
69
69
  specification_version: 4
70
70
  summary: This gem works with the Judoscale Heroku add-on to automatically scale your
71
71
  web and worker dynos.