Feature Idea: Ignore swagger on .Net Agent

I need to ignore all “swagger” transactions from my .Net Framework applications, via newrelic.config XML.
I have already added <tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory"> <match assemblyName="Swashbuckle.Core" className="Swashbuckle.Application.SwaggerDocsConfig" /> </tracerFactory>
But no change were made in my Transactions or monitored info.
What is the best way to do it?


New Relic Edit

  • I want this too
  • I have more info to share (reply below)
  • I have a solution for this

0 voters

We take feature ideas seriously and our product managers review every one when plotting their roadmaps. However, there is no guarantee this feature will be implemented. This post ensures the idea is put on the table and discussed though. So please vote and share your extra details with our team.

Hi @william.mendes1 -

From your XML it looks like you have not specified specific methods which is required.

Your XML should look something like this:

<tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory"> 
    <match assemblyName="Swashbuckle.Core" className="Swashbuckle.Application.SwaggerDocsConfig">
        <exactMethodMatcher methodName="some-method" />
    </match>
</tracerFactory>

You can add multiple <exactMethodMatcher> elements if they apply to the same assembly and classname. Otherwise you may need to create additional <match> elements.

I hope that helps. Let us know how things go.

Thank you, @Tjd.
I was thinking that was any other way of doing it, for example, ignoring all transactions from the “/swagger” or from the dll “Swashbuckle.Core.dll”, since swagger is a dependency that we do not control all methods/libraries

@william.mendes1 -

Ah, I understand your situation now.

Currently there isn’t a way to do what you would like. As you suggest there could be a number of approaches, e.g. allow “wildcarding” in the xml file or ignore transactions based on request uri or virtual path.

We’ll add this post to the .net feature ideas section of the forum to allow others to chime in as well.

Thanks!

1 Like

The Ruby Agent appears to support the following:

NEW_RELIC_RULES_IGNORE_URL_REGEXES=“swagger”

This would have been perfect…

What would an example of the methodName (swagger) be?

I am trying to prevent these requests from being monitored:

/swagger/v1.1/swagger.json
/swagger/index.html
/swagger/favicon-32x32.png

Hi @stefan.buys1,

You could use our API call

NewRelic.Api.Agent.NewRelic.IgnoreTransaction();

You will need to call it from within a transaction,FYI. It will stop the entire transaction from reporting not just the segment where you have called it from.

This document will also show you how to use Custom Instrumentation to block the transaction, however I see it was also offered as a potential work around. Im still including it as there are some worked examples listed that may be helpfull to you.
https://docs.newrelic.com/docs/agents/net-agent/custom-instrumentation/add-detail-transactions-xml-net#blocking-instrumentation

Please let me know if there is anything else I can assist with.