To use page load timing (sometimes referred to as real user monitoring or RUM) with New Relic's Ruby agent, make sure you have the latest release. To enable browser monitoring in the user interface, use the New Relic Browser settings. Then follow the procedures in this section to set up page load timing.
In order to use page load timing with your Ruby agent, make sure you meet these requirements:
- New Relic Ruby agent (version 3.0.1 or higher)
- For automatic instrumentation: Rails 2.3 or higher
- For manual instrumentation: Rails 2.0 to 2.2
Automatic instrumentation works with Rack, and therefore requires Rails 2.3 or higher.
Configure the agent to automatically instrument pages with end user monitoring
scripts, by adding or editing the following flag in
browser_monitoring: auto_instrument: true
X-UA-Compatible meta tag is present and the
<head> tag is longer than 50k, auto-instrumentation will fail gracefully.
Auto-instrumentation will look for an
X-UA-Compatible meta tag, it will insert after the opening head tag, and failing that it will insert after the opening body tag. If any of these tags are wrapped in conditionals or comments, the automatic instrumentation will likely fail.
If auto-instrumentation fails to correctly instrument your application’s pages, then you must manually instrument via agent API.
Manually instrument via agent API
If you are using Rails 2.1 to 2.2 or cannot use auto-instrumentation, you can still set up end user monitoring manually by including appropriate scripts in your pages. Use the New Relic Ruby agent's API to generate the script to be inserted into your pages.
For example, to modify your application's template to call the agent, use:
<head> <%= ::NewRelic::Agent.browser_timing_header rescue "" %> ... existing template code ... </head>
If you do not see any page load timing data being reported, view the HTML source and confirm two blocks of script similar to this in your HTML head:
If these are not present, check the auto-instrumentation settings or the placement of manual instrumentation in your template files.
In versions of the Ruby agent prior to 3.7.0,
<%=::NewRelic::Agent.browser_timing_footer rescue "" %> also needed to be called as close to the bottom of the document as possible. With 3.7.0, all the required script is included by
browser_timing_footer returns an empty string for compatibility.
The default value of
true (even when unspecified). To disable auto-instrumentation, set this flag to
To disable auto-instrumentation only for certain controllers or controller actions, use
newrelic_ignore_enduser. Server-side instrumentation will be unaffected by this call.
For more help
Additional documentation resources include: