Reputation: 1132
How can we stop logging specific module such as RequestTrackingTelemetryModule in ASP.NET MVC (.NET Full, not .NET Core)
I have tried to remove
<Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web">
in ApplicationInsights.config but it throws me a strange exception
I am using Azure Web App for both staging and live environments. So I just want to stop logging request information on live environment since it cost too much.
Thanks for helping!
Upvotes: 1
Views: 766
Reputation: 30035
You can use ITelemetryProcessor, and following this link.
Add a custom class which implements ITelemetryProcessor:
public class MyTelemetryProcessor : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
public MyTelemetryProcessor(ITelemetryProcessor next)
{
this.Next = next;
}
public void Process(ITelemetry telemetry)
{
RequestTelemetry request = telemetry as RequestTelemetry;
if (request != null)
{
return;
}
if (request == null)
{
this.Next.Process(telemetry);
}
}
}
Then in the ApplicationInsights.config, add this:
<TelemetryProcessors>
<Add Type="WebApplicationMVC.MyTelemetryProcessor, WebApplicationMVC">
<!-- Set public property -->
</Add>
</TelemetryProcessors>
the screenshot:
It did filter out all the requests from app insights data, test result as below:
Upvotes: 1