3
votes

We can no longer see the actual SQL queries being executed in Application Insights after we had upgraded our web apps to .Net Core 3.1. We left the EF Core at version 2.2 due to some serious performance issues with EF Core 3.x, so not sure if that has anything to do with that? All we see now is just the target DB details:

enter image description here

Prior to that we were on AspNetCore 2.2 with EF Core 2.2 and everything was working fine, Application Insights was showing us the actual SQL statements being executed.

We've tried the suggestions form Microsoft here, which suggested to add the Microsoft.Data.SqlClient nuget package to the project, but that did absolutely nothing.

We've also tried turning on the "Application Insights -> Sql Commands" option in our App Service, but that did nothing either.

enter image description here

Does anyone have any suggestions on how to get this working again?

Thanks

EDIT:

Nuget packages we are referencing:

enter image description here

2
Does it work locally? and also please share us the .csproj file to see which packages you're using.Ivan Yang
No, it doesn't work locally either.KenR
please share us the .csproj file to see which packages you're using.Ivan Yang
Done. Edited the postKenR
But I cannot see Microsoft.Data.SqlClient nuget package.Ivan Yang

2 Answers

3
votes

It seems that it's an issue about the latest version of Microsoft.ApplicationInsights.AspNetCore 2.14.0. I can repro the issue in 2.14.0, but it works when I downgrade it to 2.12.0.

The test result with using Microsoft.ApplicationInsights.AspNetCore 2.12.0:

enter image description here

3
votes

I believe this is because SQL command collection is off by default from version 2.14 onwards. It can be enabled with:

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

More information here: https://github.com/microsoft/ApplicationInsights-Announcements/issues/28