NewRelic - How to Ignore part of a web application

*爱你&永不变心* 提交于 2019-12-05 00:02:17

You can exclude a transaction from counting toward Apdex by calling IgnoreApdex in the New Relic .NET agent API. Add a reference to NewRelic.Agent.Api.dll in your project, then call that method in the code path common to your admin pages.

You can also ignore a transaction entirely (no Apdex, no response time, etc.) by calling IgnoreTransaction.

I'm just going to add this if someone else is looking for the same thing. The new agents now allows exclusion in the config-file, check out the answer below from their support:

The second less intrusive way is to use a "Request Path Exclusion List". The browserMonitoring-element in newrelic.config now supports (as of agent version 2.22.79.0) an optional sub-element named requestPathsExcluded, as shown below:

<browserMonitoring autoInstrument="true">
   <requestPathsExcluded>
      <path regex="About{1}?" />
      <path regex="mvcForm/Home/{1}?" />
   </requestPathsExcluded>
</browserMonitoring>

Each "path" element must contain a "regex" attribute whose value is a regular expression that can be evaluated by the .NET Framework's Regular Expression evaluator. See http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.90).aspx as a reference.

Bit late to this but if you are using MVC you could just put it into an actionfilter. You still need to take the dependency but it will at least be a lot cleaner way of invoking it:

public class PreventNewRelic : ActionFilterAttribute
{
    public override void OnActionExecuting(HttpActionContext actionContext)
    {
        NewRelic.Api.Agent.NewRelic.IgnoreTransaction();
        base.OnActionExecuting(actionContext);
    }
}

If that works by your including NewRelic javascript in your pages, then you can simply not include it on those admin pages.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!