New Relic's Ruby agent works with Sinatra 1.2.x or higher. In the New Relic UI, the Sinatra actions appear similar to controller actions. 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 Browser instrumentation. 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 New Relic Browser and the Ruby agent.