Skip to content
simple instrumentation of popular ruby libs
Ruby
Pull request Compare This branch is 13 commits behind ryandotsmith:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
instruments.gemspec
readme.md

readme.md

Instruments

Instruments enables out-of-the-box instrumentation on database & HTTP activities. Instruments supports the following libraries:

  • sinatra
  • sequel
  • excon

Usage

Provide Instruments with an object (or module) and a method and it will call the method passing a Hash containing the instrumentation data for each time instruments records a metric.

Sinatra

Modular Application

require "sinatra/base"
require "instruments"
Instruments.defaults = {
  :logger => Kernel,
  :method => :puts
}

class API < Sinatra::Base
  register Sinatra::Instruments
  instrument_routes

  get "/hello/:name" do
    params[:name]
  end
end

Classic Application

require "sinatra"
require "instruments"
Instruments.defaults = {
  :logger => Kernel,
  :method => :puts
}

instrument_routes
get "/hello/:name" do
  params[:name]
end

When you hit this endpoint, you will see the following in your log stream:

lib=sinatra action="http-request" method="get" route="/hello/:name" status=200 elapsed=0.001

Sequel

require "sequel"
require "instruments"

db = Sequel.connect(ENV["DATABASE_URL"])
db.execute("select 1")

Will produce:

lib=sequel action=select elapsed_time=0.1 sql="select 1"

Excon

require "excon"
require "instruments"

conn = Excon.new("https://www.heroku.com")
conn.get

Will produce:

lib=excon action=http-request elapsed=0

TODO

  • rest-client
  • queue_classic
  • redis

Links

Contributors

  • @konstantinhaase
  • @mmcgrana
  • @nzoschke
  • @jeremyevans
Something went wrong with that request. Please try again.