Sinatra instrumentation

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.

Contents

Getting started

Set RACK_ENV to 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.

Middleware installation

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.

Ignoring routes

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

Additionally, newrelic_ignore_apdex and newrelic_ignore_enduser are supported.

The newrelic_ignore_apdex call will exclude a given route from consideration in overall Apdex calculations.

The newrelic_ignore_enduser call will prevent automatic injection of the page load timing JavaScript when a route is rendered.

Padrino

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.