❮ Back to FAQ

Ruby Frameworks

How do I use Scout with Sinatra?

Sinatra instrumentation is similar to Rack. After installing the gem and configuring:

  1. Add the startup call in your config.ru:
require './main'
require 'scout_apm'
ScoutApm::Rack.install!
run Sinatra::Application
  1. Wrap each endpoint with transaction tracking:
get '/' do
  ScoutApm::Rack.transaction("get /", request.env) do
    "Hello!"
  end
end

Call install! after requiring other gems (ActiveRecord, Mongo, etc.) to instrument those libraries.

How do I use Scout with a generic Rack application?

Rack instrumentation involves three steps:

  1. Configure: Create config/scout_apm.yml or use environment variables

  2. Start the agent in config.ru:

require 'scout_apm'
ScoutApm::Rack.install!
run MyApp
  1. Wrap endpoints:
app = Proc.new do |env|
  ScoutApm::Rack.transaction("API User Listing", env) do
    ['200', {'Content-Type' => 'application/json'}, [users.to_json]]
  end
end

The transaction method takes a name (unchanging string describing the endpoint) and the rack environment hash.

Does Scout automatically instrument ActionController::Metal?

Yes, as of agent version 2.1.26, ActionController::Metal and ActionController::Api controllers are automatically instrumented. No additional configuration is needed.

How do I instrument Sneakers (RabbitMQ)?

Scout doesn’t automatically instrument Sneakers. To add instrumentation:

  1. Download the Sneakers integration code from Scout’s documentation
  2. Place it in your /lib folder
  3. In config/boot.rb, add: require File.expand_path('lib/scout_sneakers.rb', __FILE__)
  4. In your Worker class, after the work method, add:
class BaseWorker
  include Sneakers::Worker

  def work(attributes)
    # Do work
  end
  include ScoutApm::BackgroundJobIntegrations::Sneakers::Instruments
end

Ready to Optimize Your App?

Join engineering teams who trust Scout Monitoring for hassle-free performance monitoring. With our 3-step setup, powerful tooling, and responsive support, you can quickly identify and fix performance issues before they impact your users.