Skip to content

Engine for tracking various metrics related to a Rails 3 application

License

Notifications You must be signed in to change notification settings

engineyard/rails_metrics

Repository files navigation

RailsMetrics

RailsMetrics is an engine that hooks into your application to listen ActiveSupport::Notifications and show you statistics about them. RailsMetrics uses threads to save those notifications in the database through an in-process Queue. You can see charts based on each request and see what queries, actions, templates rendering, etc. are slow.

So far RailsMetrics supports only ActiveRecord as ORM but adding other datastore should be easy (take a look at lib/rails_metrics/orm/active_record.rb). Due to the threaded behavior in RailsMetrics, you cannot use SQLite as database, however MySQL and PostgreSQL work fine.

There’s an example application at github.com/engineyard/rails_metrics_example .

Installation

Installing RailsMetrics is simple. Since it’s a Rails::Engine, you need to install it as gem:

gem install rails_metrics

Then add it to your gemfile. So far, I recommend you to install it only on development:

group :development do
  gem "rails_metrics"
end

Finally, create your model using the built-in generator:

rails g rails_metrics Metric

You can choose another name than Metric as your rails metrics store. Run the created migration, restart your server and now you should be able to access “/rails_metrics”. Navigate on your application and head back to “/rails_metrics” to see the stored data.

Configuration

There are three parameters you can add to your application to configure RailsMetrics. The first one is to set the RailsMetrics store, which is done automatically when you use the generator:

config.rails_metrics.set_store = lambda { ::Metric }

The other parameters allows you to ignore an specific notification, based on a given block or on its name. Let’s suppose you have a plugin in your application which is yielding an useless notification. You can silence it by doing:

config.rails_metrics.ignore_patterns << /verbose_plugin/

If you need to ignore a notification based on its payload, it’s also easy:

config.rails_metrics.ignore_lambdas[:verbose_plugin] = lambda { |name, payload|
  payload[:some_value] =~ /some_expression/
}

Running the test suite

To run the test suite, please execute the following commands on the project root:

1) gem install bundler

2) bundle install

3) rake prepare

4) rake test

TODO

Please refer to TODO file.

Maintainers

Bugs and Feedback

If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.

github.com/engineyard/rails_metrics/issues

MIT License. Copyright 2010 Engine Yard. www.engineyard.com

About

Engine for tracking various metrics related to a Rails 3 application

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages