librato-metrics ruby gem 0.6.0 released — Librato Blog

librato-metrics ruby gem 0.6.0 released



Quick on the heels of previous releases, version 0.6.0 of our ruby gem, librato-metrics is out! Here's a quick look at some of what's new:

Client-Side Aggregation with Aggregators

With some metrics you care more about the range of values and distribution than about the individual values themselves (response time is a common example of this).

With the new Aggregator class you can roll up individual measurements on the client side and send a smaller number of composite measurements to Metrics. Let's look at an example assuming a metric named response_latency:

# create an aggregator
aggregator = Librato::Metrics::Aggregator.new

# add some interval measurements
aggregator.add :response_latency => 85.0
aggregator.add :response_latency => 100.5
aggregator.add :response_latency => 150.2
aggregator.add :response_latency => 90.1
aggregator.add :response_latency => 92.0

# send to Metrics
aggregator.submit

The result of these calls will report a single gauge measurement:

{:name => "response_latency", :count => 5, :sum => 517.8, :min => 85.0, :max => 150.2}

As with Queues you can also aggregate multiple metrics at once:

# add values for 'app_latency' and 'db_latency'
aggregator.add :app_latency => 35.2, :db_latency => 120.7
aggregator.add :app_latency => 36.8, :db_latency => 82.9
aggregator.submit

Time and Volume-Based Auto-Submission

Queue and Aggregator objects now support auto-submission on a set number of seconds:

 

# submit once per minute
timed_queue = Librato::Metrics::Queue.new(:autosubmit_interval => 60)

# submit every 5 minutes
timed_aggregator = Librato::Metrics::Aggregator.new(:autosubmit_interval => 300)

Queues also support auto-submitting when they hit a certain number of measurements:

# submit when the 400th measurement is queued
volume_queue = Librato::Metrics::Queue.new(:autosubmit_count => 400)
These are great options for long-running scripts where you are gathering measurements over time and then periodically flushing them in quantity. Queues automatically store the measurement time as measurements are added so you can submit several minutes worth of measurements at once.

Note that auto-submission is currently driven by adding measurements, so if you are adding measurements irregularly you may see some drift in time-based intervals. If you are using these features with scripts that run intermittently, be sure to submit any remaining measurements manually at script end to ensure that queues and aggregators are fully persisted.

Metric Delete Support

In the past if you wanted to clean up old test data or remove unwanted metrics you had to use the web interface or hit the API directly. We now support metric deletion directly within the gem:

# Delete the metrics 'temperature' and 'humidity'
Librato::Metrics.delete :temperature, :humidity

Keep in mind that deleting a metric removes the metric and all of its measurement data irreversibly, so use with care. 

Continuing Forward

We hope you've enjoyed this quick tour through some of the new features in 0.6.0. As always, more details are available in the readme and the changelog.

We have a lot more planned for the librato-metrics gem in the coming months. We hope you enjoy the new features and always appreciate your ideas and feedback. 0.6.0 is available now, so go check it out!

 

Start using Librato now. Full-featured and free for 30 days. Pricing starts at $5 per month.
I accept the Terms of Service, Privacy Policy and occasional emails from Librato. Got questions? Talk to us.