The Ruby agent automatically instruments Rack middlewares. If you are unfamiliar with the basics of Rack middlewares, review the resources linked by the Rails on Rack guide. Additionally, the Ruby agent provides some features via Rack middlewares:
- Cross application traces
- Auto-instrumentation for Browser monitoring
New Relic automatically installs these middlewares for Rails and Sinatra.
Rack instrumentation
The two most common ways to configure Rack middlewares are the Rack::Builder
API (most often from config.ru) and Rails' middleware stack configuration:
Viewing middleware data
You can view middleware data in APM.
Disabling Rack instrumentation
If you do not want to instrument Rack middlewares, you may disable Rack middleware instrumentation with the disable_middleware_instrumentation
setting. You can also ignore specific transactions.
Installing Ruby agent middlewares manually
The Ruby agent's implementation of New Relic's Cross Application Tracing feature uses Rack middleware instrumentation to read and write HTTP headers that are necessary to pass information between monitored applications. If you have disabled middleware instrumentation as described above and want to use cross application tracing, you must manually add the NewRelic::Rack::AgentHooks
middleware to your middleware stack. For more information, see Cross application tracing in Ruby.
Manual Rack instrumentation
Earlier versions of the Ruby agent supported manually instrumenting Rack middlewares via the NewRelic::Agent::Instrumentation::Rack
module. This instrumentation is deprecated in Ruby agent versions 3.9.0 or higher, because it is unnecessary with automatic middleware instrumentation. New Relic recommends that you remove references to this module from your code after upgrading to 3.9.0 or higher.
For more help
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.