Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 metrics-instrument.gemspec
README.md

Metrics client for Ruby apps

Adaptation of statsd-instrument for the (yet unreleased) metrics server.

Configuration

Metrics.server = 'statsd.myservice.com:8125'
Metrics.logger = Rails.logger
Metrics.mode = :production
Metrics.default_sample_rate = 0.1 # Sample 10% of events. By default all events are reported.

Usage

Metrics.measure

# You can pass a key and a ms value
Metrics.measure('GoogleBase.insert', 2.55)

# or more commonly pass a block that calls your code
Metrics.measure('GoogleBase.insert') do
  GoogleBase.insert(product)
end

or with metaprogramming:

GoogleBase.extend Metrics::Instrument
GoogleBase.metrics_measure :insert, 'GoogleBase.insert'

Metaprogramming methods

  • metrics_count adds '1' to the metric
  • metrics_count_if adds '1' to the metric if method returned something that evaulates to true. Takes optional block to evaluate the returned value.
  • metrics_count_success adds '1' to metric.success for successful calls and metrics.failure for failed calls.
Something went wrong with that request. Please try again.