Skip to content
Rails middleware gem for the Rails Autoscale Heroku add-on
Ruby Shell
Branch: master
Clone or download
Latest commit 27f717b Jun 25, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Update scripts and documentation Feb 21, 2017
lib prep 0.6.3 Jun 25, 2019
log Fix CI Oct 4, 2018
spec Clean up logger implementation Jun 22, 2019
.gitignore Log to file in specs Jul 9, 2017
.rspec bundle gem rails_autoscale_agent Aug 11, 2016
.ruby-version Fix CI Oct 4, 2018
.travis.yml Fix CI Oct 4, 2018
Gemfile bundle gem rails_autoscale_agent Aug 11, 2016
LICENSE.txt bundle gem rails_autoscale_agent Aug 11, 2016
README.md Logging and README updates Nov 10, 2018
Rakefile Add magic frozen string comment Oct 9, 2018
rails_autoscale_agent.gemspec Fix CI Jun 23, 2019

README.md

Rails Autoscale Agent

Build Status

This gem works together with the Rails Autoscale 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.

Requirements

Tested with Rails versions 3.2 and higher and Ruby versions 1.9.3 and higher.

Getting Started

Add this line to your application's Gemfile and run bundle:

gem 'rails_autoscale_agent'

This inserts the agent into your Rack middleware stack.

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.

Non-Rails Rack apps

You'll need to insert the RailsAutoscaleAgent::Middleware manually. Insert it before Rack::Runtime to ensure accuracy of request queue timings.

Changing the logger

If you wish to use a different logger you can set it on the configuration object:

RailsAutoscaleAgent::Config.instance.logger = MyLogger.new

What data is collected?

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:

  • Ruby version
  • Rails version
  • Gem version
  • Dyno name (example: web.1)
  • PID
  • Collection of queue time measurements (time and milliseconds)

Rails Autoscale processes and stores this information in order to power the autoscaling algorithm and dashboard visualizations.

Troubleshooting

If your logger supports tagged logging (as the Rails logger does by default), all log output from this gem is prefixed with "[RailsAutoscale]".

Once installed, you should see something like this in development:

[RailsAutoscale] Reporter not started: RAILS_AUTOSCALE_URL is not set

In production, you should see something like this:

[RailsAutoscale] Reporter starting, will report every 15 seconds

If you don't see either of these, try running bundle again and restarting your Rails application.

Reach out to help@railsautoscale.com if you run into any other problems.

Development

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.

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/adamlogic/rails_autoscale_agent.

License

The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.