Hi,
I was wondering if Application Insights offers a feature to disable localhost telemetry, so that when building and testing my ASP.NET Core website in Visual Studio 2019, that telemetry data is not sent to Azure. I have to manually remove that data in the charts and metrics in the Azure portal, using filters, as my localhost data adds noise.
If you have any suggestion about accomplish this, it would be really helpful, thank you!
Regards,
Jorge Morales
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@jmoralesv, Thanks for the question! We are taking a look into this and will get back to you soon.
@jmoralesv if you only want to prevent the sending of telemetry you can also use:
https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#disable-telemetry-dynamically
I believe you could also wrap that in a preprocessor directive.
So something like:
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, TelemetryConfiguration configuration)
{
#if DEBUG
configuration.DisableTelemetry = true;
#endif
...
}
Would probably get you closer to what you want.
@jmoralesv You could remove the ikey from your local configuration so telemetry isn't pumped to Azure. Similar ideas have been discussed here and here.
Thanks @BhargaviAnnadevara-MSFT but those examples mentioned ApplicationInsights.config which no longer exists in .NET Core 3.x.
@jmoralesv if you only want to prevent the sending of telemetry you can also use:
https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#disable-telemetry-dynamically
I believe you could also wrap that in a preprocessor directive.
So something like:
public void ConfigureServices(IServiceCollection services) { services.AddApplicationInsightsTelemetry(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, TelemetryConfiguration configuration) { #if DEBUG configuration.DisableTelemetry = true; #endif ... }
Would probably get you closer to what you want.
Thanks @mrbullwinkle I think that could work as it's for .NET Core 3.x, I'll test that out in my local environment today and see how it goes, thank you!
@jmoralesv Is there anything else you'd like us to assist you with?
Hi @BhargaviAnnadevara-MSFT
@jmoralesv Is there anything else you'd like us to assist you with?
I think we can close this case, I can see there are no more localhost traces in Application Insights when using configuration.DisableTelemetry = true;
in Debug mode.
Thank you so much for your help!
Regards,
Jorge
@jmoralesv Awesome, thanks for confirming. Happy to help!
We will now proceed to close this thread as resolved, but if there are any further questions regarding the documentation, please tag me in your reply and we will be happy to continue the conversation.
Most helpful comment
Thanks @BhargaviAnnadevara-MSFT but those examples mentioned ApplicationInsights.config which no longer exists in .NET Core 3.x.
Thanks @mrbullwinkle I think that could work as it's for .NET Core 3.x, I'll test that out in my local environment today and see how it goes, thank you!