judoscale-ruby 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06d6051251ff5f628677d931e240a35ce4f93ec8409d3e9ba8e539ec300a96d6
4
- data.tar.gz: ce94920cc35eff9f6cf328df39c84e2f0a25bd681422ab8111434311ba33cbc4
3
+ metadata.gz: 2fae3b844590300a1534b482400bc785ca8ede997a21ee4d4f93dcc37580666c
4
+ data.tar.gz: eceabb91c0e13477bbe68371a0233b6bfa111e5a5048179f2484a37b54da026c
5
5
  SHA512:
6
- metadata.gz: 21110c610a6619f3750901aade4e3a2bef813d16cfb78956225972d7b57f5769769419dcd0bf2a5d1933bf8e0760601ae35cc81d0b84078bd4232f4fadacca1d
7
- data.tar.gz: f5f7f33785b2f0554907abce78bc0e6e10dd1e2ebf773e2b5ae9fb366fa30a024de89477ee542b43c2ac09e7fcae49db944bfe879529ae0beb2dbc652f4051c5
6
+ metadata.gz: 7e070561c1727047cbc3d0cc2cb0e6a5a6334f6d04446e215c57b2f3fe18c6797e5637a3f82a766e9b47ed98fbb4d36ddf6a2e8b7e8f403ca023c527a0c0a714
7
+ data.tar.gz: ae5f5739a1b7bdf62ba808dc27ebdcc3fc9208586d61dc12b181d1fcdc9a31b1090774560b43eabf283c74cd2c9d325366be5739bbb8794dcca5fc134afdec91
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- judoscale-ruby (1.1.1)
4
+ judoscale-ruby (1.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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,9 +3,9 @@
3
3
  require "net/http"
4
4
  require "uri"
5
5
  require "json"
6
- require "rails_autoscale/logger"
6
+ require "judoscale/logger"
7
7
 
8
- module RailsAutoscale
8
+ module Judoscale
9
9
  class AdapterApi
10
10
  include Logger
11
11
 
@@ -3,7 +3,7 @@
3
3
  require "singleton"
4
4
  require "logger"
5
5
 
6
- module RailsAutoscale
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["RAILS_AUTOSCALE_URL"] || ENV["JUDOSCALE_URL"]
79
- @log_tag = ENV["JUDOSCALE_URL"] ? "Judoscale" : "RailsAutoscale"
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["RAILS_AUTOSCALE_LOG_LEVEL"] || ENV["JUDOSCALE_LOG_LEVEL"]
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,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RailsAutoscale
3
+ module Judoscale
4
4
  class JobMetricsCollector
5
5
  module ActiveRecordHelper
6
6
  # Cleanup any whitespace characters (including new lines) from the SQL for simpler logging.
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "set"
4
- require "rails_autoscale/metrics_collector"
5
- require "rails_autoscale/logger"
4
+ require "judoscale/metrics_collector"
5
+ require "judoscale/logger"
6
6
 
7
- module RailsAutoscale
7
+ module Judoscale
8
8
  class JobMetricsCollector < MetricsCollector
9
- include RailsAutoscale::Logger
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 "rails_autoscale/config"
3
+ require "judoscale/config"
4
4
  require "logger"
5
5
 
6
- module RailsAutoscale
6
+ module Judoscale
7
7
  module Logger
8
8
  def logger
9
9
  @logger ||= LoggerProxy.new(Config.instance.logger, Config.instance.log_level)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RailsAutoscale
3
+ module Judoscale
4
4
  class Metric < Struct.new(:identifier, :value, :time, :queue_name)
5
5
  # No queue_name is assumed to be a web request metric
6
6
  # Metrics: qt = queue time (default), qd = queue depth, busy
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RailsAutoscale
3
+ module Judoscale
4
4
  class MetricsCollector
5
5
  def self.collect?(config)
6
6
  true
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "singleton"
4
- require "rails_autoscale/metric"
5
- require "rails_autoscale/report"
4
+ require "judoscale/metric"
5
+ require "judoscale/report"
6
6
 
7
- module RailsAutoscale
7
+ module Judoscale
8
8
  class MetricsStore
9
9
  include Singleton
10
10
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RailsAutoscale
3
+ module Judoscale
4
4
  class Report
5
5
  attr_reader :adapters, :config, :metrics
6
6
 
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "singleton"
4
- require "rails_autoscale/config"
5
- require "rails_autoscale/logger"
6
- require "rails_autoscale/adapter_api"
7
- require "rails_autoscale/job_metrics_collector"
8
- require "rails_autoscale/web_metrics_collector"
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 RailsAutoscale
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 = RailsAutoscale.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: RAILS_AUTOSCALE_URL is not set"
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(RailsAutoscale.adapters, config, metrics)
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,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RailsAutoscale
3
+ module Judoscale
4
4
  class RequestMetrics
5
5
  attr_reader :request_id, :size, :network_time
6
6
 
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rails_autoscale/metrics_store"
4
- require "rails_autoscale/reporter"
5
- require "rails_autoscale/logger"
6
- require "rails_autoscale/request_metrics"
3
+ require "judoscale/metrics_store"
4
+ require "judoscale/reporter"
5
+ require "judoscale/logger"
6
+ require "judoscale/request_metrics"
7
7
 
8
- module RailsAutoscale
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["rails_autoscale.queue_time"] = queue_time
30
+ env["judoscale.queue_time"] = queue_time
31
31
  store.push :qt, queue_time
32
32
 
33
33
  unless network_time.zero?
34
- env["rails_autoscale.network_time"] = network_time
34
+ env["judoscale.network_time"] = network_time
35
35
  store.push :nt, network_time
36
36
  end
37
37
 
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Judoscale
4
+ VERSION = "1.2.3"
5
+ end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rails_autoscale/metrics_collector"
4
- require "rails_autoscale/metrics_store"
3
+ require "judoscale/metrics_collector"
4
+ require "judoscale/metrics_store"
5
5
 
6
- module RailsAutoscale
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
@@ -1,40 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rails_autoscale/config"
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 "rails_autoscale/version"
3
+ require "judoscale/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rails-autoscale-core"
7
- spec.version = RailsAutoscale::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 Rails Autoscale Heroku add-on to automatically scale your web and worker dynos."
12
- spec.homepage = "https://railsautoscale.com"
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://railsautoscale.com",
17
- "bug_tracker_uri" => "https://github.com/rails-autoscale/rails-autoscale-gems/issues",
18
- "documentation_uri" => "https://railsautoscale.com/docs",
19
- "changelog_uri" => "https://github.com/rails-autoscale/rails-autoscale-gems/blob/main/CHANGELOG.md",
20
- "source_code_uri" => "https://github.com/rails-autoscale/rails-autoscale-gems"
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: judoscale-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.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-23 00:00:00.000000000 Z
12
+ date: 2022-11-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -21,21 +21,23 @@ 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
42
  homepage: https://judoscale.com
41
43
  licenses:
@@ -43,7 +45,7 @@ licenses:
43
45
  metadata:
44
46
  homepage_uri: https://judoscale.com
45
47
  bug_tracker_uri: https://github.com/judoscale/judoscale-ruby/issues
46
- documentation_uri: https://railsautoscale.com/docs
48
+ documentation_uri: https://judoscale.com/docs
47
49
  changelog_uri: https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md
48
50
  source_code_uri: https://github.com/judoscale/judoscale-ruby
49
51
  post_install_message:
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RailsAutoscale
4
- VERSION = "1.1.1"
5
- end