Project

statsy

0.01
No commit activity in last 3 years
No release in over 3 years
Simple way to increment counts and measure variance in timings of everything from requests per second to single espressos
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

 Project Readme

Statsy

Cal made simple stat aggregation - And it was good.

Etsy also made simple stat aggregation - And it was also good.

This is a simple client. It supports:

  • counts
  • time measurements
  • recording gauges
  • sampling
  • batching

Requirements

This client is compatible with a Statsd server version >= 0.1.0.

Installation

Build Status

gem install statsy

Usage

Default to UDP to a host in the current search domain called 'stats' on port 8125.

client = Statsy::Client.new

Use a custom transport or change the host/port pair for UDP.

client = Statsy::Client.new(Statsy::Transport::UDP.new("graphite.acme.com", 8125))
client = Statsy::Client.new(Acme::Transport::Statsd) # <- you made that
client = Statsy::Client.new(Statsy::Transport::Queue.new) # <- if you want to test stuff

Increment by 1, arbitrary integer, or arbitrary integer at a uniform random distribution

client.increment("coffee.single-espresso")
client.increment("coffee.single-espresso", 1)
client.increment("coffee.single-espresso", 1, 0.5) # 50% of the time

Measure a timing stat that will calculate the mean, min, max, upper_90 and count

client.measure("acme.backend-runtime", response.headers["X-Runtime"].to_i)

Bonus points: Batch up many things into a fewer packets like in a shell script

loop do
  batch_lines = 1000
  client.batch do |batch|
    $stdin.each do |log_line|
      metric, timing = parse(log_line) # <- you made that
      batch.measure metric, timing
      break if (batch_lines -= 1) <= 0
    end
  end
end

These stats end up in your graphite interface under the top level keys. Look for them in this folders:

stats_counts
stats/timings
stats

Fork it out of love. Enjoy.