Server Timing Response Headers for Rails
Bring Ruby on Rails server-side performance metrics 📈 to Chrome's Developer Tools (and other browsers that support the Server Timing API) via the
server_timing gem. Production Safe™.
Add this line to your application's Gemfile:
And then execute:
A minimal Scout config file is required. The
server_timing gem reports metrics collected by the scout_apm gem (added as a dependency of
If you don't have a Scout account, copy and paste the following minimal configuration into a
common: &defaults monitor: true production: <<: *defaults
If you have a Scout account, no extra configuration is required. If you wish to see server timing metrics in development, ensure
monitor: true is set for the
development environment in the
See the scout_apm configuration reference for more information.
- Chrome 65+ (Chrome 64 uses an old format of the server timing headers. This isn't supported by the gem).
- Firefox 59+
- Opera 52+
By default, the total time consumed by each of the libraries
scout_apm instruments is reported. This includes ActiveRecord, HTTP, Redis, and more. View the full list of supported libraries.
Collect performance data on additional method calls by adding custom instrumentation via
scout_apm. See the docs for instructions.
- Non-Production Environments (ex: development, staging) - Server timing response headers are sent by default.
- Production - The headers must be enabled.
Response headers can be enabled in production by calling
# app/controllers/application_controller.rb before_action do if current_user && current_user.admin? ServerTiming::Auth.ok! end end
To only enable response headers in development and for admins in production:
# app/controllers/application_controller.rb before_action do if current_user && current_user.admin? ServerTiming::Auth.ok! elsif Rails.env.development? ServerTiming::Auth.ok! else ServerTiming::Auth.deny! end end
scout_apm gem, a dependency of
server_timing, applies low overhead instrumentation designed for production use.
After checking out the repo, run
bin/setup to install dependencies. 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.
Bug reports and pull requests are welcome on GitHub at https://github.com/scoutapp/ruby_server_timing.
The gem is available as open source under the terms of the MIT License.