Sinatra

Sinatra

Instrumenting a Sinatra application is similar to instrumenting a generic Rack application.

Configuration

The agent configuration (API key, app name, etc) follows the same process as the Rack application config.

Starting the agent

Add the ScoutApm::Rack.install! startup call as close to the spot you run your Sinatra application as possible. install! should be called after you require other gems (ActiveRecord, Mongo, etc).

require './main'

require 'scout_apm'
ScoutApm::Rack.install!

run Sinatra::Application

Adding endpoints

Wrap each endpoint in a call to ScoutApm::Rack#transaction(name, env). For example:

get '/' do
  ScoutApm::Rack.transaction("get /", request.env) do
    ActiveRecord::Base.connection.execute("SELECT * FROM pg_catalog.pg_tables")
    "Hello!"
  end
end

See our Rack docs for adding an endpoint for more details.