gpt4 book ai didi

.net - 从特定请求中删除 New Relic .NET Agent RUM 代码

转载 作者:行者123 更新时间:2023-12-02 13:56:02 25 4
gpt4 key购买 nike

我们正在使用 New Relic 的 .NET 版本。看起来好像在输出时,New Relic 解析输出以查看它是否包含任何 </head>元素并插入其 <script type="text/javascript">var NREUMQ=...前面的脚本。

我的问题是,在一个特定的闭源页面上有一行 js 内容如下:

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

...New Relic 然后将其变成...

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

...这会导致严重头痛,因为 New Relic 代码没有转义。

我想做的是以某种方式告诉 New Relic 不要在这个特定页面上注入(inject)代码,因为我无法编辑该页面。

干杯!

这里是格式漂亮的修改后的代码 - 为了您的观看乐趣(而不是响应中实际的内容)....

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

最佳答案

编辑2017-01-25
(新网址)

<小时/>

原帖
我已收到 New Relic 支持人员的答复。这是...

Hello Michael,

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

The .Net Agent injects snippets of javascript into the header and footer of pages sent to the users browser to measure the page load time on the user's end. We call this feature Real User Monitoring or RUM for short. More info about that is here: https://newrelic.com/docs/features/how-does-real-user-monitoring-work

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

<browserMonitoring autoInstrument="true"/>

to this:

<browserMonitoring autoInstrument="false"/>

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

Then you can disable the RUM on specific pages using this API call:

Or you can manually inject the header and foot where you would like them to be using these API calls:

关于.net - 从特定请求中删除 New Relic .NET Agent RUM 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18868021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com