Created: 2011-07-15 03:01
Updated: 2015-11-05 02:26
License: mit

Metrics Collector

Metrics Collector is a lightweight method of defining application metrics to aid in product decisions. Plus those metrics are integrated directly into your application which allows you to answer questions like:

  • How fast is my app growing (number of user sign-ups)?
  • Is this feature being used?

Defining those custom metrics is done by adding metric blocks to your application classes.

metric :users do

Your custom metrics are stored in a backend you define, such as an ActiveRecord model or another cool method of persisting data. Making snapshots of your metrics help you keep an accurate measure. For example, if a users deletes his account within your application and along with it all his dependent records, any calculated metrics will be incorrect.

Currently, the metrics are assumed to be collected daily other time periods will be considered later.

In the future, it will come with a Sinatra application to explore and graph those metrics using the Google Charts API.

Defining Metrics

class Image
  extend MetricCollector::ModelAdditions::ClassMethods

  metric :disk_usage do
   %x[du -s "#{Rails.root}/assets/images" | cut -f 1].chomp

  metric :images do

Collecting Metrics

MetricCollector comes with a predefined rake task: rake metrics_collector:collect.That task outputs a text reading of all metrics defined in your application.


The initial storage backend will be ActiveRecord with more to come.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more