ScoutStatsd

Build Status

Want your Rails performance KPIs in your StatsD-compatible metric system with almost zero effort? Of course you do! Meet scout_statsd! This gem is an extension of the Scout Ruby monitoring agent (scout_apm), and makes it easy to create an app performance dashboard.

A Scout account isn't required, but it certainly makes getting to the source of app performance easier 😉.

Metrics

The following metrics are reported w/o any custom instrumentation steps:

Metric Name Type Description
web.duration_ms timer The total duration of web requests in milliseconds
job.duration_ms timer The total duration of background jobs (Sidekiq, DelayedJob, etc.) in milliseconds
web.error_count counter A count of web requests that throw an exception
job.error_count counter A count of background jobs that throw an exception
web.queue_time_ms timer The time spent in request queuing in milliseconds
job.queue_time_ms timer The time between when a job is inserted into a background job queue and when execution begins in milliseconds

Now, you can correlate app performance metrics with all of your other system metrics.

Installation

Add this line to your application's Gemfile:

gem 'scout_statsd'

And then execute:

$ bundle

Or install it yourself as:

$ gem install scout_statsd

Configuration

1. Add a config/initializers/scout_statsd.rb file to your Rails app:

ScoutStatsd.configure(StatsD) # StatsD uses one of the statsd-instrument backends

Note that StatsD is a statsd-instrument client.

2. Add a config/scout_apm.yml file to your Rails app:

This step isn't required if you are already using Scout.

common: &defaults
  monitor: true

development:
  <<: *defaults
  monitor: false # set to true to test in your development environment

production:
  <<: *defaults

Metrics are only sent if monitor: true for the associated Rails environment.

See the Scout docs for advanced configuration instructions.

How it works

After each transaction (a web request or background job), the metrics specific to that transaction are transmitted via the StatsD protocol to the client passed through to ScoutStatsd#configure. No code changes are required: the scout_apm gem automatically instruments Rails controller-actions and background jobs. Easy peasy!

Contributing

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

License

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