New Relic's Ruby agent works with Sinatra 1.2.x or higher. The Sinatra actions appear in the user interface similar to controller actions, including dashboards and breakdown charts. Other features depend on your New Relic subscription level.
The actions in the UI correspond to the pattern expression used to match them. HTTP operations are not distinguished. Multiple matches are all tracked as separate actions.
To set up Sinatra:
- Install the latest
In your Sinatra app, immediately below the Sinatra require directive, add:
RACK_ENVto the environment corresponding to the configuration definitions in your newrelic.yml file; for example, development, staging, production, etc.
Note: Developer mode only works with Rails.
Ruby agent versions prior to 3.6.3 required manual addition of New Relic middlewares to enable certain features, such as cross application tracing and auto-instrumentation for page load timing (sometimes referred to as real user monitoring or RUM). For more information about required middlewares, see Rack middlewares, or upgrade to the most recent Ruby agent.
Ruby agent versions 3.6.3 or higher support ignoring certain routes, similar to what was previously available in Rails controller instrumentation. To specify these values, use the same style of routes that you use to define your Sinatra application. For example, to ignore a
ping route in a Sinatra app, include the following code in the app:
newrelic_ignore '/ping' get '/ping' do # ... end
If you want an entire application to be ignored (for example, in a mounted application), call
newrelic_ignore without parameters:
newrelic_ignore_enduser are supported.
newrelic_ignore_apdexcall will exclude a given route from consideration in overall Apdex calculations.
Padrino is a framework built on top of Sinatra. Starting with Ruby agent version 3.6.3, New Relic's Sinatra instrumentation works with Padrino versions 0.10.x or higher.
Shotgun (not supported)
The New Relic Ruby agent will not work with shotgun. It cannot make a connection before the dispatcher process exits. Neither Developer mode nor Monitor mode will work.
For more help
Additional documentation resources include:
- Middleware changes in 3.9.0 (summary of request timing changes as of Ruby agent version 3.9.0)
- Page load timing in Ruby (requirements, auto-instrumentation, manual instrumentation, and troubleshooting your Ruby agent configuration for page load timing, sometimes referred to as real user monitoring or RUM)