rails-autoscale-core 1.5.2 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/judoscale/config.rb +1 -2
- data/lib/judoscale/logger.rb +5 -1
- data/lib/judoscale/metric.rb +1 -1
- data/lib/judoscale/metrics_collector.rb +1 -13
- data/lib/judoscale/reporter.rb +11 -4
- data/lib/judoscale/version.rb +1 -1
- data/lib/judoscale-ruby.rb +1 -10
- metadata +2 -3
- data/Gemfile.lock +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7c5c0bb0fd736aaa1d20bdc0bb2211ba39e55e8652bc1d0e1532e9dec26ea38
|
4
|
+
data.tar.gz: 3aca72349348c7ba01c994839a7a4d59674bcd0087d7ea6e08707fd9b4a1a9c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123d04789e7015e6a45dc1b0e701207dae4b655dc864d8b0bf1f101984ce3e4822e19b22acf39f2c918b7ae6a627470a5eec6d6be9cb09b84748ce3b5f249e5d
|
7
|
+
data.tar.gz: b79af282afc336c17f216aa13c8dd5324faba3271a1ae8b57ae90bd0b6328d352180903cd68ac5fb9f9f4c6c82923e547cccea23930a8417813ae5db0a481cf2
|
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
|
69
69
|
attr_reader :log_level
|
70
70
|
|
71
71
|
def initialize
|
@@ -77,7 +77,6 @@ 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 = []
|
81
80
|
|
82
81
|
self.log_level = ENV["JUDOSCALE_LOG_LEVEL"] || ENV["RAILS_AUTOSCALE_LOG_LEVEL"]
|
83
82
|
@logger = ::Logger.new($stdout)
|
data/lib/judoscale/logger.rb
CHANGED
@@ -6,7 +6,11 @@ require "logger"
|
|
6
6
|
module Judoscale
|
7
7
|
module Logger
|
8
8
|
def logger
|
9
|
-
@logger
|
9
|
+
if @logger && @logger.log_level == Config.instance.log_level
|
10
|
+
@logger
|
11
|
+
else
|
12
|
+
@logger = LoggerProxy.new(Config.instance.logger, Config.instance.log_level)
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
12
16
|
|
data/lib/judoscale/metric.rb
CHANGED
@@ -5,7 +5,7 @@ module Judoscale
|
|
5
5
|
# No queue_name is assumed to be a web request metric
|
6
6
|
# Metrics: qt = queue time (default), qd = queue depth, busy
|
7
7
|
def initialize(identifier, value, time, queue_name = nil)
|
8
|
-
super
|
8
|
+
super(identifier, value.to_i, time.utc, queue_name)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -3,23 +3,11 @@
|
|
3
3
|
module Judoscale
|
4
4
|
class MetricsCollector
|
5
5
|
def self.collect?(config)
|
6
|
-
|
7
|
-
in_generator = defined?(::Rails::Command::GenerateCommand)
|
8
|
-
|
9
|
-
!in_generator && (!in_rake_task || in_whitelisted_rake_tasks?(config.allow_rake_tasks))
|
6
|
+
true
|
10
7
|
end
|
11
8
|
|
12
9
|
def collect
|
13
10
|
[]
|
14
11
|
end
|
15
|
-
|
16
|
-
def self.in_whitelisted_rake_tasks?(allowed_rake_tasks)
|
17
|
-
# Get the tasks that were invoked from the command line.
|
18
|
-
tasks = Rake.application.top_level_tasks
|
19
|
-
|
20
|
-
allowed_rake_tasks.any? do |task_regex|
|
21
|
-
tasks.any? { |task| task =~ task_regex }
|
22
|
-
end
|
23
|
-
end
|
24
12
|
end
|
25
13
|
end
|
data/lib/judoscale/reporter.rb
CHANGED
@@ -19,15 +19,13 @@ module Judoscale
|
|
19
19
|
def start!(config, adapters)
|
20
20
|
@pid = Process.pid
|
21
21
|
|
22
|
-
if
|
22
|
+
if config.api_base_url.nil? || config.api_base_url.strip.empty?
|
23
23
|
logger.debug "Set api_base_url to enable metrics reporting"
|
24
24
|
return
|
25
25
|
end
|
26
26
|
|
27
27
|
enabled_adapters, skipped_adapters = adapters.partition { |adapter|
|
28
|
-
|
29
|
-
adapter.enabled = true
|
30
|
-
end
|
28
|
+
adapter.metrics_collector&.collect?(config)
|
31
29
|
}
|
32
30
|
metrics_collectors_classes = enabled_adapters.map(&:metrics_collector)
|
33
31
|
adapters_msg = enabled_adapters.map(&:identifier).concat(
|
@@ -74,17 +72,26 @@ module Judoscale
|
|
74
72
|
@_thread&.terminate
|
75
73
|
@_thread = nil
|
76
74
|
@pid = nil
|
75
|
+
@reported = false
|
77
76
|
end
|
78
77
|
|
79
78
|
private
|
80
79
|
|
81
80
|
def report(config, metrics)
|
81
|
+
# Make sure we report at least once, even if there are no metrics,
|
82
|
+
# so Judoscale knows the adapter is installed and running.
|
83
|
+
if @reported && metrics.empty?
|
84
|
+
logger.debug "No metrics to report - skipping"
|
85
|
+
return
|
86
|
+
end
|
87
|
+
|
82
88
|
report = Report.new(Judoscale.adapters, config, metrics)
|
83
89
|
logger.info "Reporting #{report.metrics.size} metrics"
|
84
90
|
result = AdapterApi.new(config).report_metrics(report.as_json)
|
85
91
|
|
86
92
|
case result
|
87
93
|
when AdapterApi::SuccessResponse
|
94
|
+
@reported = true
|
88
95
|
logger.debug "Reported successfully"
|
89
96
|
when AdapterApi::FailureResponse
|
90
97
|
logger.error "Reporter failed: #{result.failure_message}"
|
data/lib/judoscale/version.rb
CHANGED
data/lib/judoscale-ruby.rb
CHANGED
@@ -21,17 +21,8 @@ module Judoscale
|
|
21
21
|
end
|
22
22
|
|
23
23
|
class Adapter < Struct.new(:identifier, :adapter_info, :metrics_collector)
|
24
|
-
attr_accessor :enabled
|
25
|
-
|
26
|
-
def initialize(identifier, adapter_info, metrics_collector)
|
27
|
-
super
|
28
|
-
self.enabled = false
|
29
|
-
end
|
30
|
-
|
31
24
|
def as_json
|
32
|
-
{
|
33
|
-
identifier => adapter_info.merge(enabled: enabled)
|
34
|
-
}
|
25
|
+
{identifier => adapter_info}
|
35
26
|
end
|
36
27
|
end
|
37
28
|
|
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.5.
|
4
|
+
version: 1.5.4
|
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:
|
13
|
+
date: 2024-02-07 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description:
|
16
16
|
email:
|
@@ -20,7 +20,6 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- Gemfile
|
23
|
-
- Gemfile.lock
|
24
23
|
- Rakefile
|
25
24
|
- judoscale-ruby.gemspec
|
26
25
|
- lib/judoscale-ruby.rb
|
data/Gemfile.lock
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
judoscale-ruby (1.5.2)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
addressable (2.8.1)
|
10
|
-
public_suffix (>= 2.0.2, < 6.0)
|
11
|
-
crack (0.4.5)
|
12
|
-
rexml
|
13
|
-
debug (1.7.1)
|
14
|
-
irb (>= 1.5.0)
|
15
|
-
reline (>= 0.3.1)
|
16
|
-
hashdiff (1.0.1)
|
17
|
-
io-console (0.6.0)
|
18
|
-
irb (1.6.2)
|
19
|
-
reline (>= 0.3.0)
|
20
|
-
minitest (5.17.0)
|
21
|
-
minitest-stub-const (0.6)
|
22
|
-
public_suffix (5.0.1)
|
23
|
-
rake (13.0.6)
|
24
|
-
reline (0.3.2)
|
25
|
-
io-console (~> 0.5)
|
26
|
-
rexml (3.2.5)
|
27
|
-
webmock (3.18.1)
|
28
|
-
addressable (>= 2.8.0)
|
29
|
-
crack (>= 0.3.2)
|
30
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
31
|
-
|
32
|
-
PLATFORMS
|
33
|
-
arm64-darwin-20
|
34
|
-
arm64-darwin-21
|
35
|
-
arm64-darwin-22
|
36
|
-
x86_64-darwin-21
|
37
|
-
x86_64-linux
|
38
|
-
|
39
|
-
DEPENDENCIES
|
40
|
-
debug
|
41
|
-
judoscale-ruby!
|
42
|
-
minitest
|
43
|
-
minitest-stub-const
|
44
|
-
rake (>= 12.3.3)
|
45
|
-
webmock
|
46
|
-
|
47
|
-
BUNDLED WITH
|
48
|
-
2.3.9
|