• Stars
    star
    516
  • Rank 85,726 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bring Rails server-side performance metrics 📈 to Chrome's Developer Tools via the Server Timing API. Production Safe™.

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™.

Metrics are collected from the scout_apm gem. A Scout account is not required.

server timing screenshot

Gem Installation

Add this line to your application's Gemfile:

gem 'server_timing'

And then execute:

$ bundle

Configuration

A minimal Scout config file is required. The server_timing gem reports metrics collected by the scout_apm gem (added as a dependency of server_timing).

If you don't have a Scout account, copy and paste the following minimal configuration into a RAILS_ROOT/config/scout_apm.yml file:

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 scout_apm.yml file.

See the scout_apm configuration reference for more information.

Browser Support

  • Chrome 65+ (Chrome 64 uses an old format of the server timing headers. This isn't supported by the gem).
  • Firefox 59+
  • Opera 52+

Instrumentation

Auto-Instrumentation

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.

Custom Instrumentation

Collect performance data on additional method calls by adding custom instrumentation via scout_apm. See the docs for instructions.

Security

  • 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 ServerTiming::Auth.ok!:

# 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

Overhead

The scout_apm gem, a dependency of server_timing, applies low overhead instrumentation designed for production use.

Development

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.

Contributing

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

License

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

More Repositories

1

scout_realtime

Realtime server metrics in your browser
JavaScript
2,092
star
2

scout_apm_ruby

ScoutAPM Ruby Agent. Supports Rails, Sinatra, Grape, Rack, and many other frameworks
Ruby
200
star
3

scout_apm_python

ScoutAPM Python Agent. Supports Django, Flask, and many other frameworks.
Python
69
star
4

elixir_plug_server_timing

Bring Elixir/Phoenix server-side performance metrics 📈 to Chrome's Developer Tools via the Server Timing API. Production Safe™.
Elixir
48
star
5

scout_apm_elixir

ScoutAPM Elixir Agent. Supports Phoenix and other frameworks.
Elixir
36
star
6

scout-apm-laravel

ScoutAPM PHP Agent for the Laravel Framework
22
star
7

roadmap

The public roadmap for Scout application monitoring.
16
star
8

scout-apm-php

ScoutAPM's Base PHP Agent - See README for Laravel, Symfony, and other framework support.
PHP
16
star
9

scout-apm-php-ext

Native Extension Component for ScoutAPM's PHP Agent
C
15
star
10

scout_statsd_rack

Rack application monitoring with StatsD
Ruby
9
star
11

scout_apm_node

ScoutAPM Agent for NodeJS. Supports Express and other frameworks
TypeScript
8
star
12

scout_dogstatsd_ruby

Report Rails app performance metrics (response time, error rate, throughput, etc) via the DogStatsD client
Ruby
7
star
13

profile_it_agent

A Ruby gem for detailed in-browser Rails profiling analysis. Metrics are reported to profileit.io.
Ruby
6
star
14

ollama-django

Python
3
star
15

load_test_rails_4

Rails application to benchmark APM Agents.
Ruby
3
star
16

core-agent-api

Instrument apps written in languages Scout doesn't officially support with the Core Agent API
3
star
17

mtls_example

A quick launch mTLS repository.
Shell
2
star
18

scout-apm-symfony-bundle

ScoutAPM Support for Symfony Applications
2
star
19

scout_apm_go

Early experiment in Golang instrumentation
Go
2
star
20

standalone_grape_example

Example of how to monitor a Standalone Grape API with Scout APM
Ruby
2
star
21

scout-apm-lumen

2
star
22

fieldbook

The Rails Performance Field Guide
CSS
2
star
23

scout_help_sphinx

Scout Help Docs powered by Sphinx
1
star
24

rails_demo

Rails app for demo contains some common performance issues
Ruby
1
star
25

scout_signalfx_ruby

Bring key health metrics for your Ruby on Rails app into SignalFx
Ruby
1
star