Permalink
Browse files

Doc improvements.

  • Loading branch information...
nextmat committed Dec 6, 2011
1 parent 9ed7ffa commit d28fb6bb8f84d7ed376cf64fe39b1ec0e56e722a
Showing with 44 additions and 14 deletions.
  1. +27 −4 README.md
  2. +0 −1 lib/librato/metrics.rb
  3. +0 −6 lib/librato/metrics/persistence.rb
  4. +17 −3 lib/librato/metrics/simple.rb
View
@@ -5,13 +5,36 @@ A convenient Ruby wrapper for the Librato Metrics API.
## Installation
+On your shell:
+
gem install librato-metrics
-## Standard Usage
+Then, in your application or script:
+
+ require 'librato/metrics'
+
+## Quick Start
+
+If you are looking for the quickest possible route to getting a data into Metrics, you only need two lines:
+
+ Librato::Metrics.authenticate 'email', 'api_key'
+ Librato::Metrics.save :my_metric => 42
+
+Unspecified metrics will send a *gauge*, but if you need to send a different metric type or include additional properties, simply use a hash for the value:
+
+ Librato::Metrics.send :my_metric => {:type => :counter, :value => 1002, :source => 'myapp'}
+
+While this is all you need to get started, this probably isn't the most performant option for you, so read on...
+
+## Authentication
+
+The metrics gem supports multiple methods of persistence, but by default it communicates directly with the Metrics web API.
+
+Make sure you have an [account for Metrics](https://metrics.librato.com/) and then authenticate with your email and API key (you can find it on your account page):
-Set up your credentials:
+ Librato::Metrics.authenticate 'email', 'api_key'
- Librato::Metrics.authenticate 'username', 'api_key'
+## Sending Metrics
Queue up a simple gauge metric named `temperature`:
@@ -28,7 +51,7 @@ Queue up a metric with a source:
Send queued metrics:
- metric_set.send
+ metric_set.save
## Contribution
View
@@ -11,7 +11,6 @@ module Metrics
extend SingleForwardable
# TODO: Explain exposed interface with examples.
-
def_delegators Librato::Metrics::Simple, :authenticate, :persistence,
:persistence=, :persister, :save
@@ -1,9 +1,3 @@
-module Librato
- module Metrics
- module Persistence; end
- end
-end
-
require 'metrics/persistence/direct'
require 'metrics/persistence/test'
@@ -1,5 +1,3 @@
-# this class contains logic used when the module is called in short-form operations.
-
module Librato
module Metrics
@@ -17,20 +15,36 @@ class Simple
class << self
# class instance vars
- attr_accessor :email, :api_key, :persistence
+ attr_accessor :email, :api_key
+ # Authenticate for direct persistence
+ #
+ # @param [String] email
+ # @param [String] api_key
def authenticate(email, api_key)
self.email, self.api_key = email, api_key
end
+ # Persistence type to use when saving metrics.
+ # Default is :direct.
+ #
def persistence
@persistence ||= :direct
end
+ # Set persistence type to use when saving metrics.
+ #
+ # @param [Symbol] persistence_type
+ def persistence=(method)
+ @perisistence = method
+ end
+
def persister
@metric_set ? @metric_set.persister : nil
end
+ # Submit a set of metrics
+ #
def save(args)
@metric_set ||= MetricSet.new
@metric_set.queue args

0 comments on commit d28fb6b

Please sign in to comment.