Remove the new RUM REAL.NET Agent code from the specific request

We are using the version of the new .NET replica. It appears that on output, New Relic parses the result to see if it contains any </head> elements and inserts it <script type="text/javascript">var NREUMQ=... script before that.

My problem is that on a separate closed source page there is a js line that reads ...

 document.write("<html><head></head><body></body></html>"); 

... a new relic then turns it into ...

 document.write("<html><head><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script></head><body></body></html>"); 

... which causes severe headaches as the new relic code is not escaped.

What I would like to do is tell New Relic so that it does not enter the code on this page, since I cannot edit the page.

Hooray!

Here is the modified code in a nice format - for your viewing pleasure (not really in the answer) ....

 document.write("<html><head><script type="text/javascript"> var NREUMQ=NREUMQ||[]; NREUMQ.push(["mark","firstbyte",new Date().getTime()]); </script></head><body></body></html>"); 
+4
source share
4 answers

EDIT 2017-01-25
(new URLs)


ORIGINAL MAIL
I received a response from New Relic support. Here it is...

Hi Michael,

This is a fantastic question! There is a very direct way of doing what you want to do.

The .Net agent injects javascript fragments in the header and footer of the pages sent to the users browser to measure page load time at the end of the user. We call this feature Real User Monitoring or RUM for short. More on this here: https://newrelic.com/docs/features/how-does-real-user-monitoring-work

If you want to completely disable RUM on all pages, you can edit newrelic.config and change this line:

 <browserMonitoring autoInstrument="true"/> 

:

 <browserMonitoring autoInstrument="false"/> 

You can disable RUM on individual pages and / or manually specify where fragments of the RUF header / footer are entered on the page using the API.Net API. To use this library, add a link to NewRelic.Api.Agent.dll for your project. The DLL should be found in this folder: "%ProgramFiles%\New Relic\.NET Agent"

You can then disable RUM on specific pages with this API call:

Or you can manually enter the header and foot where you want them to use these API calls:

+3
source

Today I faced the same problem. I was able to fix this by associating Javascript with a combination of “he” and “ad” on the client. This prevents the viewing of the New Relic RUM HEI tag.

document.write("<html><he" + "ad></he" + "ad><body></body></html>");

+1
source

I just want to add to Gerrard's answer. His solution worked for me, but I also had to break the BODY tag. The new Relic is thoughtful enough to add its own HEAD tag before the BODY tag after it could not detect my original HEAD tag.

As a side note, this automatic equipment caused me a lot of pain in several projects.

0
source

Actually, it’s much easier to solve this problem by adding one line of code to your cshtml or aspx file:

 NewRelic.Api.Agent.NewRelic.DisableBrowserMonitoring(); 
0
source

Source: https://habr.com/ru/post/1502759/


All Articles