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
Usage
Metrics.measure
Metrics.measure('GoogleBase.insert', 2.55)
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 metricmetrics_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.