Troubleshooting New Relic RUM issues

Posted by on Oct 25, 2012 in .NET, Windows Azure | No Comments

Once your web application is up and running, one of the most important things as a developer is visibility of what is going on inside the application. You can use server logging, remote desktop access, automated exception alert emails and various other techniques to get this information but in general it’s a messy and fragmented process.

I’ve been developing on Windows Azure for quite a while now and recently came across a great solution for this called New Relic. It’s a SaaS application monitoring system and I’ve been blown away by how quick it is to set up, the detail of the data you get back from your application and how it is presented in their web interface.

One of the major features of New Relic is its real-time user monitoring (RUM) which provides a ton of useful data about the user accessing your application such as page load times,
network time, DOM processing and page rendering. When I installed New Relic on a Windows Azure .NET application recently I had some issues getting RUM to work correctly so I wanted to share my experience in case anyone comes across a similar problem.

RUM works by injecting small JavaScript snippets into top and bottom of the output of your pages before they are sent to the client. By default New Relic does this automatically.

When I initially deployed New Relic into my application I came across JavaScript errors in some pages which turned out to be the result of the auto instrumentation injecting the RUM snippet into existing <script> tags in our aspx page markup rather than right at the bottom of page before the </body> tag as it should.

The New Relic documentation states that you can instruct the agent to insert the RUM snippets at a location of your choice rather than using the auto instrumentation so this was my next step. I added the new ContentPlaceholder controls to my master page, the header into the <head> tag:

<asp:ContentPlaceHolder ID="NewRelic_BrowserTimingHeader" runat="server" />

and the footer just prior to the </body> tag:

<asp:ContentPlaceHolder ID="NewRelic_BrowserTimingFooter" runat="server" />

This fixed the JavaScript errors I was having but unfortunately created a much more serious problem on any pages that utilised UpdatePanel or in my case RadAjaxPanel controls (from the Telerik controls suite). These pages would throw an exception stating that there were multiple controls in the page with the same ID namely the NewRelic_BrowserTimingHeader or NewRelic_BrowserTimingFooter.

My thought here was that perhaps the New Relic agent was creating the controls automatically via its default auto-instrumentation as well as via the manual ContentPlaceholder tags I’d added. To try and solve this I disabled auto-instrumentation by updating the line in the newrelic.xml file in the root or our .NET application:

<browserMonitoring autoInstrument="false" />

This didn’t work and after much investigation I found out that the reason was that the newrelic.xml wasn’t being copied correctly by the deployment process. Once you’ve followed the instructions in the New Relic documentation, make sure that in the Properties of the newrelic.xml file in your solution you set the Copy to Output Directory setting to Copy always. If you don’t then this file won’t be available to the newrelic.cmd file when your deployment is unpackaged in Azure and the New Relic settings will remain as their default values.

Disabling the auto-instrumentation was the last step and I now have fully functional RUM data coming into New Relic!


Leave a Reply