rails_autoscale_agent 0.9.0.beta.5 → 0.9.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: f151c5012b2d2a5bb76f17ed4b4ee7f8f751ef9657c7f4b9d42d4d86fda7c654
4
- data.tar.gz: 4773c138b97d723aa44f803ccb504facdf4c619995122296561933b5363d8910
3
+ metadata.gz: cd7ffb8cd27de3a23d5e76bd9a9c7768ce1fd397389291285022523fb398ee45
4
+ data.tar.gz: d8cf3fa7ab2994ef196742fe872170c069dc6f14bc0490b595ff175e48ce59e6
5
5
  SHA512:
6
- metadata.gz: 432f9ea93f5c722f286a0bec54f22c477583f0b0501cff64498f2d710fdd5e3f674753443d017ab43cefc04d0b8b2263227554992e84f023b13074392d004e15
7
- data.tar.gz: 1ba59eb800d04044e78e2c5462fe373dc4d81e1b14de72d4a41f3454acf4a4a0739067f8371ad2d31372badf2c222dffc0b13c2ef0c01e542d12d218a6c1981f
6
+ metadata.gz: '0976e83784dd6a622b18a67491e727cbe9f0fb1a54e1974f50b61f441f642a296b5a4e3349e2f4d292acc35c844765527c16e097cf7ac914a7224b68e2ae8bd6'
7
+ data.tar.gz: 2de7d8a61d44fd408cfbab88b1be37327bd5836da8c125f4c61f80ac7503c0a44c5ee5f893919eb5487e4a34a817102a68aabd76699d34d6ce3086680b8aceb7
data/README.md CHANGED
@@ -24,16 +24,6 @@ The agent will only communicate with Rails Autoscale if a `RAILS_AUTOSCALE_URL`
24
24
 
25
25
  You'll need to insert the `RailsAutoscaleAgent::Middleware` manually. Insert it before `Rack::Runtime` to ensure accuracy of request queue timings.
26
26
 
27
- ## Changing the logger
28
-
29
- The Rails logger is used by default.
30
- If you wish to use a different logger you can set it on the configuration object:
31
-
32
- ```ruby
33
- # config/initializers/rails_autoscale_agent.rb
34
- RailsAutoscaleAgent::Config.instance.logger = MyLogger.new
35
- ```
36
-
37
27
  ## What data is collected?
38
28
 
39
29
  The middleware agent runs in its own thread so your web requests are not impacted. The following data is submitted periodically to the Rails Autoscale API:
@@ -59,17 +49,39 @@ In production, run `heroku logs -t | grep RailsAutoscale`, and you should see so
59
49
 
60
50
  If you don't see either of these, try running `bundle` again and restarting your Rails application.
61
51
 
62
- You can see more detailed (debug) logging by setting the `RAILS_AUTOSCALE_DEBUG` env var on your Heroku app:
52
+ You can see more detailed (debug) logging by setting `RAILS_AUTOSCALE_DEBUG` on your Heroku app:
63
53
 
64
54
  ```
65
55
  heroku config:add RAILS_AUTOSCALE_DEBUG=true
66
56
  ```
67
57
 
68
- Debug logs are silenced by default because Rails apps default to a DEBUG log level in production,
69
- and these can get very noisy with this gem.
58
+ See more in the [logging](#logging) section below.
70
59
 
71
60
  Reach out to help@railsautoscale.com if you run into any other problems.
72
61
 
62
+ ## Logging
63
+
64
+ The Rails logger is used by default.
65
+ If you wish to use a different logger you can set it on the configuration object:
66
+
67
+ ```ruby
68
+ # config/initializers/rails_autoscale_agent.rb
69
+ RailsAutoscaleAgent::Config.instance.logger = MyLogger.new
70
+ ```
71
+
72
+ Debug logs are silenced by default because Rails apps default to a DEBUG log level in production, and this gem has _very_ chatty debug logs. If you want to see the debug logs, set `RAILS_AUTOSCALE_DEBUG` on your Heroku app:
73
+
74
+ ```
75
+ heroku config:add RAILS_AUTOSCALE_DEBUG=true
76
+ ```
77
+
78
+ If you find the gem too chatty even without this, you can quiet it down further:
79
+
80
+ ```ruby
81
+ # config/initializers/rails_autoscale_agent.rb
82
+ RailsAutoscaleAgent::Config.instance.quiet = true
83
+ ```
84
+
73
85
  ## Development
74
86
 
75
87
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -7,7 +7,7 @@ module RailsAutoscaleAgent
7
7
  include Singleton
8
8
 
9
9
  attr_accessor :report_interval, :logger, :api_base_url, :max_request_size,
10
- :dyno, :pid, :addon_name, :worker_adapters, :dev_mode
10
+ :dyno, :pid, :addon_name, :worker_adapters, :dev_mode, :debug, :quiet
11
11
 
12
12
  def initialize
13
13
  require 'rails_autoscale_agent/worker_adapters/sidekiq'
@@ -25,11 +25,12 @@ module RailsAutoscaleAgent
25
25
  @addon_name = ENV['RAILS_AUTOSCALE_ADDON'] || 'RAILS_AUTOSCALE'
26
26
  @api_base_url = ENV["#{@addon_name}_URL"]
27
27
  @dev_mode = ENV['RAILS_AUTOSCALE_DEV'] == 'true'
28
+ @debug = dev_mode? || ENV['RAILS_AUTOSCALE_DEBUG'] == 'true'
28
29
  @pid = Process.pid
29
30
  @max_request_size = 100_000 # ignore request payloads over 100k since they skew the queue times
30
31
  @report_interval = 10 # this default will be overwritten during Reporter#register!
31
32
  @logger ||= defined?(Rails) ? Rails.logger : ::Logger.new(STDOUT)
32
- @dyno = @dev_mode ? 'dev.1' : ENV['DYNO']
33
+ @dyno = dev_mode? ? 'dev.1' : ENV['DYNO']
33
34
  end
34
35
 
35
36
  def to_s
@@ -41,5 +42,7 @@ module RailsAutoscaleAgent
41
42
  end
42
43
 
43
44
  alias_method :dev_mode?, :dev_mode
45
+ alias_method :debug?, :debug
46
+ alias_method :quiet?, :quiet
44
47
  end
45
48
  end
@@ -13,26 +13,33 @@ module RailsAutoscaleAgent
13
13
  class LoggerProxy < Struct.new(:logger)
14
14
  TAG = '[RailsAutoscale]'
15
15
 
16
- %w[info warn error].each do |name|
17
- define_method name do |msg|
18
- logger.send name, tag(msg)
19
- end
16
+ def error(msg)
17
+ logger.error tag(msg)
18
+ end
19
+
20
+ def warn(msg)
21
+ logger.warn tag(msg)
22
+ end
23
+
24
+ def info(msg)
25
+ logger.info tag(msg) unless Config.instance.quiet?
20
26
  end
21
27
 
22
28
  def debug(msg)
23
29
  # Silence debug logs by default to avoiding being overly chatty (Rails logger defaults
24
- # to DEBUG level in production).
25
- # This uses a separate logger so that RAILS_AUTOSCALE_DEBUG
26
- # shows debug logs regardless of Rails log level.
27
- debug_logger.debug tag(msg) if ENV['RAILS_AUTOSCALE_DEBUG'] == 'true' || Config.instance.dev_mode?
30
+ # to DEBUG level in production). Setting RAILS_AUTOSCALE_DEBUG=true enables debug logs,
31
+ # even if the underlying logger severity level is INFO.
32
+ if Config.instance.debug?
33
+ if logger.respond_to?(:debug?) && logger.debug?
34
+ logger.debug tag(msg)
35
+ elsif logger.respond_to?(:info?) && logger.info?
36
+ logger.info tag("[DEBUG] #{msg}")
37
+ end
38
+ end
28
39
  end
29
40
 
30
41
  private
31
42
 
32
- def debug_logger
33
- @debug_loggers ||= ::Logger.new(STDOUT)
34
- end
35
-
36
43
  def tag(msg)
37
44
  "#{TAG} #{msg}"
38
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAutoscaleAgent
4
- VERSION = "0.9.0.beta.5"
4
+ VERSION = "0.9.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_autoscale_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0.beta.5
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam McCrea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-28 00:00:00.000000000 Z
11
+ date: 2020-07-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -63,9 +63,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  version: '0'
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.3.1
68
+ version: '0'
69
69
  requirements: []
70
70
  rubygems_version: 3.1.4
71
71
  signing_key: