rails_autoscale_agent 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -19
- data/lib/rails_autoscale_agent/logger.rb +9 -2
- data/lib/rails_autoscale_agent/reporter.rb +1 -1
- data/lib/rails_autoscale_agent/request.rb +3 -3
- data/lib/rails_autoscale_agent/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: 9599e5eb723b8e92f13eb6f820ce7f49f6af5ae946146eb140f13e42a465625a
|
4
|
+
data.tar.gz: 94eeec3ac6376605b5d0db1c8aa406c1f7101fddbf2f188e1cbb41c5f2f836bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8d33309ab62d23341bc707e8b5e5da5158e21885911fd0418a58c5880b4fe24a309cabf3cd08513382e18570e7c28f8ff2fa1bb7362f040aac8f3210fdf306e
|
7
|
+
data.tar.gz: 41999dbec255f00d7f3369f97e81acae12c556b126050ea28a50816a8c91801a8dfa256cdfc14f8126c4ad175ecd9dc16fd3b8136aaf0c9805301a362cdf81de
|
data/README.md
CHANGED
@@ -2,14 +2,11 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/adamlogic/rails_autoscale_agent.svg?branch=master)](https://travis-ci.org/adamlogic/rails_autoscale_agent)
|
4
4
|
|
5
|
-
This gem works together with the Rails Autoscale Heroku add-on
|
6
|
-
to automatically scale your web dynos as needed.
|
7
|
-
It gathers a minimal set of metrics for each request,
|
8
|
-
and periodically posts this data asynchronously to the Rails Autoscale service.
|
5
|
+
This gem works together with the [Rails Autoscale](https://railsautoscale.com) Heroku add-on to automatically scale your web dynos as needed. It gathers a minimal set of metrics for each request, and periodically posts this data asynchronously to the Rails Autoscale service.
|
9
6
|
|
10
7
|
## Requirements
|
11
8
|
|
12
|
-
|
9
|
+
Tested with Rails versions 3.2 and higher and Ruby versions 1.9.3 and higher.
|
13
10
|
|
14
11
|
## Getting Started
|
15
12
|
|
@@ -19,17 +16,13 @@ Add this line to your application's Gemfile and run `bundle`:
|
|
19
16
|
gem 'rails_autoscale_agent'
|
20
17
|
```
|
21
18
|
|
22
|
-
This
|
19
|
+
This inserts the agent into your Rack middleware stack.
|
23
20
|
|
24
|
-
The agent will only communicate with Rails Autoscale if a `RAILS_AUTOSCALE_URL` ENV variable is present,
|
25
|
-
which happens automatically when you install the Heroku add-on.
|
26
|
-
In development (or anytime the ENV var is missing), the middleware will still produce
|
27
|
-
`INFO`-level log output to your Rails log.
|
21
|
+
The agent will only communicate with Rails Autoscale if a `RAILS_AUTOSCALE_URL` ENV variable is present, which happens automatically when you install the Heroku add-on. The middleware does nothing if `RAILS_AUTOSCALE_URL` is not present, such as in development or a staging app.
|
28
22
|
|
29
23
|
## Non-Rails Rack apps
|
30
24
|
|
31
|
-
You'll need to insert the `RailsAutoscaleAgent::Middleware` manually. Insert it
|
32
|
-
before `Rack::Runtime` to ensure accuracy of request queue timings.
|
25
|
+
You'll need to insert the `RailsAutoscaleAgent::Middleware` manually. Insert it before `Rack::Runtime` to ensure accuracy of request queue timings.
|
33
26
|
|
34
27
|
## Changing the logger
|
35
28
|
|
@@ -39,16 +32,40 @@ If you wish to use a different logger you can set it on the configuration object
|
|
39
32
|
RailsAutoscaleAgent::Config.instance.logger = MyLogger.new
|
40
33
|
```
|
41
34
|
|
35
|
+
## What data is collected?
|
36
|
+
|
37
|
+
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:
|
38
|
+
|
39
|
+
- Ruby version
|
40
|
+
- Rails version
|
41
|
+
- Gem version
|
42
|
+
- Dyno name (example: web.1)
|
43
|
+
- PID
|
44
|
+
- Collection of queue time measurements (time and milliseconds)
|
45
|
+
|
46
|
+
Rails Autoscale processes and stores this information in order to power the autoscaling algorithm and dashboard visualizations.
|
47
|
+
|
48
|
+
## Troubleshooting
|
49
|
+
|
50
|
+
If your logger supports tagged logging (as the Rails logger does by default), all log output from this gem is prefixed with "[RailsAutoscale]".
|
51
|
+
|
52
|
+
Once installed, you should see something like this in development:
|
53
|
+
|
54
|
+
> [RailsAutoscale] Reporter not started: RAILS_AUTOSCALE_URL is not set
|
55
|
+
|
56
|
+
In production, you should see something like this:
|
57
|
+
|
58
|
+
> [RailsAutoscale] Reporter starting, will report every 15 seconds
|
59
|
+
|
60
|
+
If you don't see either of these, try running `bundle` again and restarting your Rails application.
|
61
|
+
|
62
|
+
Reach out to help@railsautoscale.com if you run into any other problems.
|
63
|
+
|
42
64
|
## Development
|
43
65
|
|
44
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
45
|
-
Then, run `rake spec` to run the tests.
|
46
|
-
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
66
|
+
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.
|
47
67
|
|
48
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
49
|
-
To release a new version, update the version number in `version.rb`,
|
50
|
-
and then run `bundle exec rake release`, which will create a git tag for the version,
|
51
|
-
push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
68
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
52
69
|
|
53
70
|
## Contributing
|
54
71
|
|
@@ -2,10 +2,17 @@
|
|
2
2
|
|
3
3
|
module RailsAutoscaleAgent
|
4
4
|
module Logger
|
5
|
-
|
6
5
|
def logger
|
7
|
-
@logger ||= Config.instance.logger
|
6
|
+
@logger ||= Config.instance.logger.tap do |logger|
|
7
|
+
logger.extend(FakeTaggedLogging) unless logger.respond_to?(:tagged)
|
8
|
+
end
|
8
9
|
end
|
9
10
|
|
11
|
+
module FakeTaggedLogging
|
12
|
+
def tagged(*tags)
|
13
|
+
# NOTE: Quack like ActiveSupport::TaggedLogging, but don't reimplement
|
14
|
+
yield self
|
15
|
+
end
|
16
|
+
end
|
10
17
|
end
|
11
18
|
end
|
@@ -59,7 +59,7 @@ module RailsAutoscaleAgent
|
|
59
59
|
|
60
60
|
case result
|
61
61
|
when AutoscaleApi::SuccessResponse
|
62
|
-
logger.
|
62
|
+
logger.debug "Reported successfully"
|
63
63
|
when AutoscaleApi::FailureResponse
|
64
64
|
logger.error "Reporter failed: #{result.failure_message}"
|
65
65
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RailsAutoscaleAgent
|
4
4
|
class Request
|
5
5
|
include Logger
|
6
|
-
|
6
|
+
|
7
7
|
attr_reader :id, :entered_queue_at, :path, :method, :size
|
8
8
|
|
9
9
|
def initialize(env, config)
|
@@ -26,11 +26,11 @@ module RailsAutoscaleAgent
|
|
26
26
|
if entered_queue_at
|
27
27
|
if entered_queue_at < (Time.now - 60 * 10)
|
28
28
|
# ignore unreasonable values
|
29
|
-
logger.
|
29
|
+
logger.warn "request queued for more than 10 minutes... skipping collection"
|
30
30
|
else
|
31
31
|
queue_time = ((Time.now - entered_queue_at) * 1000).to_i
|
32
32
|
queue_time = 0 if queue_time < 0
|
33
|
-
logger.
|
33
|
+
logger.debug "Collected queue_time=#{queue_time}ms request_id=#{id} request_size=#{size}"
|
34
34
|
|
35
35
|
queue_time
|
36
36
|
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam McCrea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|