Instrumenting a Sinatra application is similar to instrumenting a generic Rack application.
The agent configuration (API key, app name, etc) follows the same process as the Rack application config.
Starting the agent
ScoutApm::Rack.install! startup call as close to the spot you
run your Sinatra application as possible.
should be called after you require other gems (ActiveRecord, Mongo, etc).
require './main' require 'scout_apm' ScoutApm::Rack.install! run Sinatra::Application
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.