microsoft / ApplicationInsights-Announcements

Subscribe to this repo to be notified about major changes in Application Insights.
38 stars 13 forks source link

C# 2.14 Update: SQL command collection off by default #28

Open ank3it opened 4 years ago

ank3it commented 4 years ago

As part of C# SDK 2.14 release updates, a new breaking change will be released to the public. To adhere to compliance and security standards, Microsoft Application Insights (.NET/.NET Core) SDKs will no longer collect SQL commands in any format, by default.

The change itself, will now align the behaviors of ASP.NET Core and ASP.NET SDKs.

Our earlier behavior looked as follows:

Our new behavior for both ASP.NET & ASP.NET Core customers will look as follows:

FAQs

How do I delete any previous data?

Users who wish to delete any previous commands executed and stored in the past 30 days can use the purge command available here: https://docs.microsoft.com/en-us/rest/api/application-insights/components/purge

How do I enable SQL Text collection?

ASP.NET Core

Modify ConfigureServices() with the line below:

services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module, o) => { module. EnableSqlCommandTextInstrumentation = true; }); 

Doc: https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#configuring-or-removing-default-telemetrymodules

ASP.NET

Modify ApplicationInsights.config file to have this line.

<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">, 
<EnableSqlCommandTextInstrumentation>true</EnableSqlCommandTextInstrumentation>
</Add>

For ASP.NET customers, the above alone is insufficient to collect SQL text, if using System.Data.SqlClient.

Additional platform-specific steps, documented below, should be followed.

https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-dependencies#advanced-sql-tracking-to-get-full-sql-query