0.0
No release in over 3 years
Low commit activity in last 3 years
SimpleMetric is a Rails plugin offering easy solution for storing and plotting measurements for your app
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0

Runtime

>= 3.1
~> 1.0.5
 Project Readme

SimpleMetric

Rails metric solution. Store data-points, display graphs. Based on dygraphs js lib.

Gem Version

Example

example 1

Usage

Add some data points:

SimpleMetric::Metric.add_data_point "Users count", 30.days.ago, 10
SimpleMetric::Metric.add_data_point "Users count", 20.days.ago, 15
SimpleMetric::Metric.add_data_point "Users count", 10.days.ago, 25

Add many data points:

SimpleMetric::Metric.add_data_points(
  ["Users count", 30.days.ago, 10],
  ["Sales count", 10.days.ago, 1000]
)

Display graph into your erb template:

<%= simple_metric_graph "Users count" %>

Plot multiple metrics:

<%= simple_metric_graph "metric_1", "metric_2" %>

Add custom titles:

<%= simple_metric_graph ["metric_1", "Title for metric 1"], ["metric_2", "Title 2"] %>

Installation

Add this line to your application's Gemfile:

gem 'simple-metric'

And then execute:

$ bundle

Or install it yourself as:

$ gem install simple-metric

Add migration

By generator:

rails g active_record:simple_metric Metric

or by rails migration:

$ rails g migration create_metrics

Insert that:

...

def change
    create_table :metrics do |t|
    t.string :key
    t.text :data_set

    t.timestamps
    end

    add_index :metrics, :key, :unique => true
end

...

Run migration:

$ rake db:migrate

Include dygraph js lib into your application.js:

//= require dygraph-combined

Contributing

  1. Fork it ( https://github.com/sergio-fry/simple-metric/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request