New Relic

The New Relic Ruby agent monitors your applications to help you identify and solve performance issues. You can also extend the agent’s performance monitoring to collect and analyze business data to help you improve the customer experience and make data-driven business decisions.

The Ruby agent supports many of the most common Ruby frameworks and platforms. You can also use the Ruby agent in a Google App Engine (GAE) flexible environment

Ruby custom instrumentation

The New Relic Ruby agent automatically collects many metrics. It also includes an API you can use to collect additional metrics about your application. If you see large Application Code segments in transaction trace details, custom instrumentation can give a more complete picture of what is going on in your application.

Method tracers

The easiest way to capture custom instrumentation is by tracing calls to a particular method. Tracing a method as described below will insert an additional node in your transaction traces for each invocation of that method, providing greater detail about where time is going in your transactions.

Method tracers are software probes you can put on a method of any class. The probes use alias method chaining to insert themselves when the target methods execute and gather custom instrumentation on their performance.


Tracing initializers

For Rails, a common way to add instrumentation is to create an initializer and “monkey patch” the instrumentation directives.For example, to add a method tracer to MyCache#get:

Make sure the Cache class is loaded before adding the method tracer.

Add the following in a file named config/initializers/rpm_instrumentation.rb:

Tracing blocks of code:

Sometimes a single method is so complex that tracking overall time doesn’t give enough detail. In these cases, you can wrap a block of code with a tracer. Call trace_execution_scoped passing the code to trace 


  • Find errors and problems quickly
  • Track key transactions.
  • Create customized dashboards for important metrics.
  • Alert your team when errors or problems occur before they affect your users.
  • Track performance after a deployment.