在rails中删除某些路由的newrelic rum.js脚本

Tit*_*tas 3 html instrumentation http attachment newrelic

我正在使用newrelic ruby​​代理,它正在从我的app中为每个hmtl响应插入一些js代码,例如在head:var NREUMQ = []; NREUMQ.push(["mark","firstbyte",new Date()).的getTime()]);

问题是,我们允许用户托管内容,有时他们托管html文件.然后newrelic在点击下载时将这些行插入到他们的html中......

示例html通过网站下载并添加了新增内容.有关如何仅针对某些路由或我们只能用于特定代码路径的任何其他方法剥离新的东西的任何建议吗?

HTTP/1.1 200 OK
Server: nginx/1.1.8
Date: Thu, 26 Apr 2012 19:25:54 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1176
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11
X-UA-Compatible: IE=Edge,chrome=1
Content-Transfer-Encoding: binary
X-Runtime: 0.340155
Progma: cache
Content-Disposition: attachment; filename="404.html"
Expires: 0
Cache-Control: private
Set-Cookie: ;)
Status: 200

<!DOCTYPE html>
<html>
<head><script>var NREUMQ=[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
  <title>The page you were looking for doesn't exist (404)</title>
  <style type="text/css">
    body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
    div.dialog {
      width: 25em;
      padding: 0 4em;
      margin: 4em auto 0 auto;
      border: 1px solid #ccc;
      border-right-color: #999;
      border-bottom-color: #999;
    }
    h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
  </style>
</head>

<body>
  <!-- This file lives in public/404.html -->
  <div class="dialog">
    <h1>The page you were looking for doesn't exist.</h1>
    <p>You may have mistyped the address or the page may have moved.</p>
  </div>
<script>(function(){var d=document;var e=d.createElement("script");e.async=true;e.src="https://d1ros97qkrwjf5.cloudfront.net/30/eum/rum.js";var s=d.getElementsByTagName("script")[0];s.parentNode.insertBefore(e,s);})();NREUMQ.push(["nrf2","beacon-1.newrelic.com","9dfe439095",309309,"blablabla==",0,336,new Date().getTime()])</script></body>
</html>
Run Code Online (Sandbox Code Playgroud)

我尝试过使用:include NewRelic :: Agent :: Instrumentation :: ControllerInstrumentation newrelic_ignore:only =>"download"在我的控制器中,但似乎没有任何效果.

当我重新启动乘客时,代码不会在短时间内附加到任何页面,之后,它会被所有页面,甚至是那些具有newrelic_ignore的页面

rkb*_*rkb 5

您可以关闭New Relic RUM的自动检测 - 这就是在页面中自动插入JS的内容.有一个设置newrelic.yml可以打开和关闭自动RUM.有关详细信息,请参阅Ruby中RUM文档.

完成此操作后,您可以手动为要测量最终用户页面加载时间的操作添加返回检测.文档中还描述了如何执行此操作 - 您可以调用Ruby代理API方法在页面中插入页眉和页脚.

  • 在与New Relic客户支持部门交谈之后,这只能在全球范围内完成,然后单独添加. (4认同)