No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Easily output formatted metrics to stdout
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 0.9.0
~> 10.0
~> 2.14
 Project Readme

Formatted Metrics

Build Status Code Climate

Easily produce metrics that can be consumed by l2met or statsd.

Installation

Add this line to your application's Gemfile:

gem 'formatted-metrics'

Usage

Rack

If you want to instrument rack request times:

use Rack::Instrumentation

Instrument

Use Metrics.instrument to instrument events to STDOUT.

Metrics.instrument 'rack.request' do
  @app.call(env)
end
# => 'source=app measure.rack.request=50ms'

Metrics.instrument 'workers.busy', 10, units: 'workers'
# => 'source=app measure.workers.busy=10workers'

Metrics.instrument 'sidekiq.queue', source: 'background' do
  yield
end
# => 'source=app.background measure.sidekiq.queue=500ms'

Metrics.group 'sidekiq' do |group|
  group.instrument 'queues.process', 100, units: 'jobs'
  group.instrument 'workers.busy', 10, units: 'workers'

  group.instrument 'queue.time', source: 'worker.1' do
    sleep 1
  end
end

# => 'source=app measure.sidekiq.queues.processed=100jobs measure.sidekiq.workers.busy=10workers'
# => 'source=app.worker.1 measure.sidekiq.queue.time=1000.00ms'

TODO

  • Add Rack middleware for outputting rack performance metrics.
  • Instrument some default rails stuff.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request