rails-autoscale-core 1.1.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +5 -2
- data/Rakefile +1 -1
- data/judoscale-ruby.gemspec +27 -0
- data/lib/{rails_autoscale → judoscale}/adapter_api.rb +2 -2
- data/lib/{rails_autoscale → judoscale}/config.rb +4 -4
- data/lib/{rails_autoscale → judoscale}/job_metrics_collector/active_record_helper.rb +1 -1
- data/lib/{rails_autoscale → judoscale}/job_metrics_collector.rb +4 -4
- data/lib/{rails_autoscale → judoscale}/logger.rb +2 -2
- data/lib/{rails_autoscale → judoscale}/metric.rb +1 -1
- data/lib/{rails_autoscale → judoscale}/metrics_collector.rb +1 -1
- data/lib/{rails_autoscale → judoscale}/metrics_store.rb +3 -3
- data/lib/{rails_autoscale → judoscale}/report.rb +1 -1
- data/lib/{rails_autoscale → judoscale}/reporter.rb +9 -9
- data/lib/{rails_autoscale → judoscale}/request_metrics.rb +1 -1
- data/lib/{rails_autoscale → judoscale}/request_middleware.rb +7 -7
- data/lib/judoscale/version.rb +5 -0
- data/lib/{rails_autoscale → judoscale}/web_metrics_collector.rb +3 -3
- data/lib/judoscale-ruby.rb +40 -0
- data/lib/rails-autoscale-core.rb +1 -38
- data/rails-autoscale-core.gemspec +9 -9
- metadata +26 -24
- data/lib/rails_autoscale/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 964dfef811345b3e60c86525ccf5cfa2ea6f8711e6e5a6361cfd61006421be06
|
4
|
+
data.tar.gz: eceabb91c0e13477bbe68371a0233b6bfa111e5a5048179f2484a37b54da026c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7b350c828704f4b4a7aec702e85e03bb49066516a198c4c94f4b1bfc5d8da70fc006ca437a7d0abf5511e24996e168850ffc2c271a0ac72386d41952f8c3e37
|
7
|
+
data.tar.gz: ae5f5739a1b7bdf62ba808dc27ebdcc3fc9208586d61dc12b181d1fcdc9a31b1090774560b43eabf283c74cd2c9d325366be5739bbb8794dcca5fc134afdec91
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
4
|
+
judoscale-ruby (1.2.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -20,6 +20,8 @@ GEM
|
|
20
20
|
minitest (5.15.0)
|
21
21
|
public_suffix (5.0.0)
|
22
22
|
rake (13.0.6)
|
23
|
+
rake-release (1.3.0)
|
24
|
+
bundler (>= 1.11, < 3)
|
23
25
|
reline (0.3.1)
|
24
26
|
io-console (~> 0.5)
|
25
27
|
rexml (3.2.5)
|
@@ -36,9 +38,10 @@ PLATFORMS
|
|
36
38
|
|
37
39
|
DEPENDENCIES
|
38
40
|
debug
|
41
|
+
judoscale-ruby!
|
39
42
|
minitest
|
40
|
-
rails-autoscale-core!
|
41
43
|
rake (>= 12.3.3)
|
44
|
+
rake-release
|
42
45
|
webmock
|
43
46
|
|
44
47
|
BUNDLED WITH
|
data/Rakefile
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "judoscale/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "judoscale-ruby"
|
7
|
+
spec.version = Judoscale::VERSION
|
8
|
+
spec.authors = ["Adam McCrea", "Carlos Antonio da Silva"]
|
9
|
+
spec.email = ["adam@adamlogic.com"]
|
10
|
+
|
11
|
+
spec.summary = "This gem works with the Judoscale Heroku add-on to automatically scale your web and worker dynos."
|
12
|
+
spec.homepage = "https://judoscale.com"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.metadata = {
|
16
|
+
"homepage_uri" => "https://judoscale.com",
|
17
|
+
"bug_tracker_uri" => "https://github.com/judoscale/judoscale-ruby/issues",
|
18
|
+
"documentation_uri" => "https://judoscale.com/docs",
|
19
|
+
"changelog_uri" => "https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md",
|
20
|
+
"source_code_uri" => "https://github.com/judoscale/judoscale-ruby"
|
21
|
+
}
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.required_ruby_version = ">= 2.6.0"
|
27
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "singleton"
|
4
4
|
require "logger"
|
5
5
|
|
6
|
-
module
|
6
|
+
module Judoscale
|
7
7
|
class Config
|
8
8
|
class Dyno
|
9
9
|
attr_reader :name, :num
|
@@ -75,12 +75,12 @@ module RailsAutoscale
|
|
75
75
|
|
76
76
|
def reset
|
77
77
|
# Allow the API URL to be configured - needed for testing.
|
78
|
-
@api_base_url = ENV["
|
79
|
-
@log_tag =
|
78
|
+
@api_base_url = ENV["JUDOSCALE_URL"] || ENV["RAILS_AUTOSCALE_URL"]
|
79
|
+
@log_tag = "Judoscale"
|
80
80
|
self.dyno = ENV["DYNO"]
|
81
81
|
@max_request_size_bytes = 100_000 # ignore request payloads over 100k since they skew the queue times
|
82
82
|
@report_interval_seconds = 10
|
83
|
-
self.log_level = ENV["
|
83
|
+
self.log_level = ENV["JUDOSCALE_LOG_LEVEL"] || ENV["RAILS_AUTOSCALE_LOG_LEVEL"]
|
84
84
|
@logger = ::Logger.new($stdout)
|
85
85
|
|
86
86
|
self.class.adapter_configs.each(&:reset)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "set"
|
4
|
-
require "
|
5
|
-
require "
|
4
|
+
require "judoscale/metrics_collector"
|
5
|
+
require "judoscale/logger"
|
6
6
|
|
7
|
-
module
|
7
|
+
module Judoscale
|
8
8
|
class JobMetricsCollector < MetricsCollector
|
9
|
-
include
|
9
|
+
include Judoscale::Logger
|
10
10
|
|
11
11
|
# It's redundant to report these metrics from every dyno, so only report from the first one.
|
12
12
|
def self.collect?(config)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "judoscale/config"
|
4
4
|
require "logger"
|
5
5
|
|
6
|
-
module
|
6
|
+
module Judoscale
|
7
7
|
module Logger
|
8
8
|
def logger
|
9
9
|
@logger ||= LoggerProxy.new(Config.instance.logger, Config.instance.log_level)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "singleton"
|
4
|
-
require "
|
5
|
-
require "
|
4
|
+
require "judoscale/metric"
|
5
|
+
require "judoscale/report"
|
6
6
|
|
7
|
-
module
|
7
|
+
module Judoscale
|
8
8
|
class MetricsStore
|
9
9
|
include Singleton
|
10
10
|
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "singleton"
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
require "
|
4
|
+
require "judoscale/config"
|
5
|
+
require "judoscale/logger"
|
6
|
+
require "judoscale/adapter_api"
|
7
|
+
require "judoscale/job_metrics_collector"
|
8
|
+
require "judoscale/web_metrics_collector"
|
9
9
|
|
10
|
-
module
|
10
|
+
module Judoscale
|
11
11
|
class Reporter
|
12
12
|
include Singleton
|
13
13
|
include Logger
|
14
14
|
|
15
|
-
def self.start(config = Config.instance, adapters =
|
15
|
+
def self.start(config = Config.instance, adapters = Judoscale.adapters)
|
16
16
|
instance.start!(config, adapters) unless instance.started?
|
17
17
|
end
|
18
18
|
|
@@ -20,7 +20,7 @@ module RailsAutoscale
|
|
20
20
|
@pid = Process.pid
|
21
21
|
|
22
22
|
if !config.api_base_url
|
23
|
-
logger.info "Reporter not started:
|
23
|
+
logger.info "Reporter not started: JUDOSCALE_URL is not set"
|
24
24
|
return
|
25
25
|
end
|
26
26
|
|
@@ -76,7 +76,7 @@ module RailsAutoscale
|
|
76
76
|
private
|
77
77
|
|
78
78
|
def report(config, metrics)
|
79
|
-
report = Report.new(
|
79
|
+
report = Report.new(Judoscale.adapters, config, metrics)
|
80
80
|
logger.info "Reporting #{report.metrics.size} metrics"
|
81
81
|
result = AdapterApi.new(config).report_metrics(report.as_json)
|
82
82
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
require "
|
3
|
+
require "judoscale/metrics_store"
|
4
|
+
require "judoscale/reporter"
|
5
|
+
require "judoscale/logger"
|
6
|
+
require "judoscale/request_metrics"
|
7
7
|
|
8
|
-
module
|
8
|
+
module Judoscale
|
9
9
|
class RequestMiddleware
|
10
10
|
include Logger
|
11
11
|
|
@@ -27,11 +27,11 @@ module RailsAutoscale
|
|
27
27
|
store = MetricsStore.instance
|
28
28
|
|
29
29
|
# NOTE: Expose queue time to the app
|
30
|
-
env["
|
30
|
+
env["judoscale.queue_time"] = queue_time
|
31
31
|
store.push :qt, queue_time
|
32
32
|
|
33
33
|
unless network_time.zero?
|
34
|
-
env["
|
34
|
+
env["judoscale.network_time"] = network_time
|
35
35
|
store.push :nt, network_time
|
36
36
|
end
|
37
37
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
3
|
+
require "judoscale/metrics_collector"
|
4
|
+
require "judoscale/metrics_store"
|
5
5
|
|
6
|
-
module
|
6
|
+
module Judoscale
|
7
7
|
class WebMetricsCollector < MetricsCollector
|
8
8
|
def self.collect?(config)
|
9
9
|
config.dyno.name == "web"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "judoscale/config"
|
4
|
+
require "judoscale/version"
|
5
|
+
|
6
|
+
module Judoscale
|
7
|
+
# Allows configuring Rails Autoscale through a block, usually defined during application initialization.
|
8
|
+
#
|
9
|
+
# Example:
|
10
|
+
#
|
11
|
+
# Judoscale.configure do |config|
|
12
|
+
# config.logger = MyLogger.new
|
13
|
+
# end
|
14
|
+
def self.configure
|
15
|
+
yield Config.instance
|
16
|
+
end
|
17
|
+
|
18
|
+
@adapters = []
|
19
|
+
class << self
|
20
|
+
attr_reader :adapters
|
21
|
+
end
|
22
|
+
|
23
|
+
Adapter = Struct.new(:identifier, :adapter_info, :metrics_collector) do
|
24
|
+
def as_json
|
25
|
+
{identifier => adapter_info}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.add_adapter(identifier, adapter_info, metrics_collector: nil, expose_config: nil)
|
30
|
+
Config.expose_adapter_config(expose_config) if expose_config
|
31
|
+
@adapters << Adapter.new(identifier, adapter_info, metrics_collector)
|
32
|
+
end
|
33
|
+
|
34
|
+
add_adapter :"judoscale-ruby", {
|
35
|
+
adapter_version: VERSION,
|
36
|
+
language_version: RUBY_VERSION
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
RailsAutoscale = Judoscale
|
data/lib/rails-autoscale-core.rb
CHANGED
@@ -1,40 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "rails_autoscale/version"
|
5
|
-
|
6
|
-
module RailsAutoscale
|
7
|
-
# Allows configuring Rails Autoscale through a block, usually defined during application initialization.
|
8
|
-
#
|
9
|
-
# Example:
|
10
|
-
#
|
11
|
-
# RailsAutoscale.configure do |config|
|
12
|
-
# config.logger = MyLogger.new
|
13
|
-
# end
|
14
|
-
def self.configure
|
15
|
-
yield Config.instance
|
16
|
-
end
|
17
|
-
|
18
|
-
@adapters = []
|
19
|
-
class << self
|
20
|
-
attr_reader :adapters
|
21
|
-
end
|
22
|
-
|
23
|
-
Adapter = Struct.new(:identifier, :adapter_info, :metrics_collector) do
|
24
|
-
def as_json
|
25
|
-
{identifier => adapter_info}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.add_adapter(identifier, adapter_info, metrics_collector: nil, expose_config: nil)
|
30
|
-
Config.expose_adapter_config(expose_config) if expose_config
|
31
|
-
@adapters << Adapter.new(identifier, adapter_info, metrics_collector)
|
32
|
-
end
|
33
|
-
|
34
|
-
add_adapter :"rails-autoscale-core", {
|
35
|
-
adapter_version: VERSION,
|
36
|
-
language_version: RUBY_VERSION
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
Judoscale = RailsAutoscale
|
3
|
+
require "judoscale-ruby"
|
@@ -1,23 +1,23 @@
|
|
1
1
|
lib = File.expand_path("../lib", __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "
|
3
|
+
require "judoscale/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "rails-autoscale-core"
|
7
|
-
spec.version =
|
7
|
+
spec.version = Judoscale::VERSION
|
8
8
|
spec.authors = ["Adam McCrea", "Carlos Antonio da Silva"]
|
9
9
|
spec.email = ["adam@adamlogic.com"]
|
10
10
|
|
11
|
-
spec.summary = "This gem works with the
|
12
|
-
spec.homepage = "https://
|
11
|
+
spec.summary = "This gem works with the Judoscale Heroku add-on to automatically scale your web and worker dynos."
|
12
|
+
spec.homepage = "https://judoscale.com"
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
15
15
|
spec.metadata = {
|
16
|
-
"homepage_uri" => "https://
|
17
|
-
"bug_tracker_uri" => "https://github.com/
|
18
|
-
"documentation_uri" => "https://
|
19
|
-
"changelog_uri" => "https://github.com/
|
20
|
-
"source_code_uri" => "https://github.com/
|
16
|
+
"homepage_uri" => "https://judoscale.com",
|
17
|
+
"bug_tracker_uri" => "https://github.com/judoscale/judoscale-ruby/issues",
|
18
|
+
"documentation_uri" => "https://judoscale.com/docs",
|
19
|
+
"changelog_uri" => "https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md",
|
20
|
+
"source_code_uri" => "https://github.com/judoscale/judoscale-ruby"
|
21
21
|
}
|
22
22
|
|
23
23
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-autoscale-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam McCrea
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-11-
|
12
|
+
date: 2022-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -21,31 +21,33 @@ files:
|
|
21
21
|
- Gemfile
|
22
22
|
- Gemfile.lock
|
23
23
|
- Rakefile
|
24
|
+
- judoscale-ruby.gemspec
|
25
|
+
- lib/judoscale-ruby.rb
|
26
|
+
- lib/judoscale/adapter_api.rb
|
27
|
+
- lib/judoscale/config.rb
|
28
|
+
- lib/judoscale/job_metrics_collector.rb
|
29
|
+
- lib/judoscale/job_metrics_collector/active_record_helper.rb
|
30
|
+
- lib/judoscale/logger.rb
|
31
|
+
- lib/judoscale/metric.rb
|
32
|
+
- lib/judoscale/metrics_collector.rb
|
33
|
+
- lib/judoscale/metrics_store.rb
|
34
|
+
- lib/judoscale/report.rb
|
35
|
+
- lib/judoscale/reporter.rb
|
36
|
+
- lib/judoscale/request_metrics.rb
|
37
|
+
- lib/judoscale/request_middleware.rb
|
38
|
+
- lib/judoscale/version.rb
|
39
|
+
- lib/judoscale/web_metrics_collector.rb
|
24
40
|
- lib/rails-autoscale-core.rb
|
25
|
-
- lib/rails_autoscale/adapter_api.rb
|
26
|
-
- lib/rails_autoscale/config.rb
|
27
|
-
- lib/rails_autoscale/job_metrics_collector.rb
|
28
|
-
- lib/rails_autoscale/job_metrics_collector/active_record_helper.rb
|
29
|
-
- lib/rails_autoscale/logger.rb
|
30
|
-
- lib/rails_autoscale/metric.rb
|
31
|
-
- lib/rails_autoscale/metrics_collector.rb
|
32
|
-
- lib/rails_autoscale/metrics_store.rb
|
33
|
-
- lib/rails_autoscale/report.rb
|
34
|
-
- lib/rails_autoscale/reporter.rb
|
35
|
-
- lib/rails_autoscale/request_metrics.rb
|
36
|
-
- lib/rails_autoscale/request_middleware.rb
|
37
|
-
- lib/rails_autoscale/version.rb
|
38
|
-
- lib/rails_autoscale/web_metrics_collector.rb
|
39
41
|
- rails-autoscale-core.gemspec
|
40
|
-
homepage: https://
|
42
|
+
homepage: https://judoscale.com
|
41
43
|
licenses:
|
42
44
|
- MIT
|
43
45
|
metadata:
|
44
|
-
homepage_uri: https://
|
45
|
-
bug_tracker_uri: https://github.com/
|
46
|
-
documentation_uri: https://
|
47
|
-
changelog_uri: https://github.com/
|
48
|
-
source_code_uri: https://github.com/
|
46
|
+
homepage_uri: https://judoscale.com
|
47
|
+
bug_tracker_uri: https://github.com/judoscale/judoscale-ruby/issues
|
48
|
+
documentation_uri: https://judoscale.com/docs
|
49
|
+
changelog_uri: https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md
|
50
|
+
source_code_uri: https://github.com/judoscale/judoscale-ruby
|
49
51
|
post_install_message:
|
50
52
|
rdoc_options: []
|
51
53
|
require_paths:
|
@@ -64,6 +66,6 @@ requirements: []
|
|
64
66
|
rubygems_version: 3.2.32
|
65
67
|
signing_key:
|
66
68
|
specification_version: 4
|
67
|
-
summary: This gem works with the
|
68
|
-
|
69
|
+
summary: This gem works with the Judoscale Heroku add-on to automatically scale your
|
70
|
+
web and worker dynos.
|
69
71
|
test_files: []
|