judoscale-ruby 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +3 -1
- data/lib/judoscale/config.rb +5 -2
- data/lib/judoscale/job_metrics_collector.rb +1 -1
- data/lib/judoscale/metrics_collector.rb +12 -1
- data/lib/judoscale/reporter.rb +6 -4
- data/lib/judoscale/version.rb +1 -1
- 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: 34e63423106d499e2a555bf9343d38224e1eeb1e4f2fa2177d532ff33df3de81
|
4
|
+
data.tar.gz: 7efed4c6de8f587dac09c10ede982a67f73aba88e6ffeb3275db19dc968f1df7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2858316d5ec92aaca9b448a30699fb64dae7a970a97bf3bd4e54437d5ed5877782efd2b2c698e7c45e5f1c122b652c6463d26e98349c248cf580869bea974aa6
|
7
|
+
data.tar.gz: 659d23cad27612aff9c3653890758a40a315eaea4e3d319cbb0d36ada38568a00168e13601220ef06dcec7ed49dec325accd1fb844924665e031d7e32bfd4fa4
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
judoscale-ruby (1.5.
|
4
|
+
judoscale-ruby (1.5.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -18,6 +18,7 @@ GEM
|
|
18
18
|
irb (1.6.2)
|
19
19
|
reline (>= 0.3.0)
|
20
20
|
minitest (5.17.0)
|
21
|
+
minitest-stub-const (0.6)
|
21
22
|
public_suffix (5.0.1)
|
22
23
|
rake (13.0.6)
|
23
24
|
reline (0.3.2)
|
@@ -39,6 +40,7 @@ DEPENDENCIES
|
|
39
40
|
debug
|
40
41
|
judoscale-ruby!
|
41
42
|
minitest
|
43
|
+
minitest-stub-const
|
42
44
|
rake (>= 12.3.3)
|
43
45
|
webmock
|
44
46
|
|
data/lib/judoscale/config.rb
CHANGED
@@ -65,7 +65,7 @@ module Judoscale
|
|
65
65
|
end
|
66
66
|
|
67
67
|
attr_accessor :api_base_url, :report_interval_seconds,
|
68
|
-
:max_request_size_bytes, :logger, :log_tag, :current_runtime_container
|
68
|
+
:max_request_size_bytes, :logger, :log_tag, :current_runtime_container, :allow_rake_tasks
|
69
69
|
attr_reader :log_level
|
70
70
|
|
71
71
|
def initialize
|
@@ -77,6 +77,7 @@ module Judoscale
|
|
77
77
|
@log_tag = "Judoscale"
|
78
78
|
@max_request_size_bytes = 100_000 # ignore request payloads over 100k since they skew the queue times
|
79
79
|
@report_interval_seconds = 10
|
80
|
+
@allow_rake_tasks = []
|
80
81
|
|
81
82
|
self.log_level = ENV["JUDOSCALE_LOG_LEVEL"] || ENV["RAILS_AUTOSCALE_LOG_LEVEL"]
|
82
83
|
@logger = ::Logger.new($stdout)
|
@@ -86,7 +87,9 @@ module Judoscale
|
|
86
87
|
if ENV["RENDER_INSTANCE_ID"]
|
87
88
|
instance = ENV["RENDER_INSTANCE_ID"].delete_prefix(ENV["RENDER_SERVICE_ID"]).delete_prefix("-")
|
88
89
|
@current_runtime_container = RuntimeContainer.new instance
|
89
|
-
|
90
|
+
# Allow a custom API base URL to be set for Render (for testing)
|
91
|
+
@api_base_url ||= "https://adapter.judoscale.com/api"
|
92
|
+
@api_base_url += "/#{ENV["RENDER_SERVICE_ID"]}"
|
90
93
|
elsif ENV["DYNO"]
|
91
94
|
@current_runtime_container = RuntimeContainer.new ENV["DYNO"]
|
92
95
|
elsif (metadata_uri = ENV["ECS_CONTAINER_METADATA_URI"])
|
@@ -9,7 +9,7 @@ module Judoscale
|
|
9
9
|
include Judoscale::Logger
|
10
10
|
|
11
11
|
def self.collect?(config)
|
12
|
-
!config.current_runtime_container.redundant_instance? && adapter_config.enabled
|
12
|
+
super && !config.current_runtime_container.redundant_instance? && adapter_config.enabled
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.adapter_name
|
@@ -3,11 +3,22 @@
|
|
3
3
|
module Judoscale
|
4
4
|
class MetricsCollector
|
5
5
|
def self.collect?(config)
|
6
|
-
|
6
|
+
in_rake_task = defined?(::Rake) && Rake.respond_to?(:application) && Rake.application.top_level_tasks.any?
|
7
|
+
|
8
|
+
!in_rake_task || in_whitelisted_rake_tasks?(config.allow_rake_tasks)
|
7
9
|
end
|
8
10
|
|
9
11
|
def collect
|
10
12
|
[]
|
11
13
|
end
|
14
|
+
|
15
|
+
def self.in_whitelisted_rake_tasks?(allowed_rake_tasks)
|
16
|
+
# Get the tasks that were invoked from the command line.
|
17
|
+
tasks = Rake.application.top_level_tasks
|
18
|
+
|
19
|
+
allowed_rake_tasks.any? do |task_regex|
|
20
|
+
tasks.any? { |task| task =~ task_regex }
|
21
|
+
end
|
22
|
+
end
|
12
23
|
end
|
13
24
|
end
|
data/lib/judoscale/reporter.rb
CHANGED
@@ -20,23 +20,25 @@ module Judoscale
|
|
20
20
|
@pid = Process.pid
|
21
21
|
|
22
22
|
if !config.api_base_url
|
23
|
-
logger.debug "
|
23
|
+
logger.debug "Set api_base_url to enable metrics reporting"
|
24
24
|
return
|
25
25
|
end
|
26
26
|
|
27
|
-
enabled_adapters = adapters.
|
27
|
+
enabled_adapters, skipped_adapters = adapters.partition { |adapter|
|
28
|
+
# judoscale-ruby adapter does not have a metrics collector
|
28
29
|
adapter.metrics_collector.nil? || adapter.metrics_collector.collect?(config)
|
29
30
|
}
|
30
31
|
metrics_collectors_classes = enabled_adapters.map(&:metrics_collector)
|
31
32
|
metrics_collectors_classes.compact!
|
32
33
|
|
33
34
|
if metrics_collectors_classes.empty?
|
34
|
-
|
35
|
+
adapters_msg = skipped_adapters.map(&:identifier).join(", ")
|
36
|
+
logger.debug "No metrics need to be collected (adapters: #{adapters_msg})"
|
35
37
|
return
|
36
38
|
end
|
37
39
|
|
38
40
|
adapters_msg = enabled_adapters.map(&:identifier).join(", ")
|
39
|
-
logger.info "Reporter starting, will report every
|
41
|
+
logger.info "Reporter starting, will report every ~#{config.report_interval_seconds} seconds (adapters: #{adapters_msg})"
|
40
42
|
|
41
43
|
metrics_collectors = metrics_collectors_classes.map(&:new)
|
42
44
|
|
data/lib/judoscale/version.rb
CHANGED
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.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam McCrea
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-08-09 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description:
|
16
16
|
email:
|