With the Ruby agent, you can add New Relic Browser instrumentation to your webpages either automatically or manually. To enable Browser in the user interface, follow the procedures to install the Browser agent. Then follow the procedures in this section to set up the Ruby agent.
In order to use New Relic Browser 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 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
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.
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 Browser 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.