0
votes

Our application is using azure application insights. What I read is that, using application insights end to end tracking, we can even get the query which gets executed at database and how much time that query took.

But as shown in the screenshot, azure app insights shows me that there are 3 calls made to database but not the actual query that was executed against the database in those calls.

What I need to know is that what i need to do inorder to get the query that was executed against the database?

enter image description here

2
It's a .net core project or .net framework project?Ivan Yang

2 Answers

5
votes

This is one of breaking changes as part of SDK 2.14.

You just need to simply modify ConfigureServices() with the line below for ASP.NET Core:

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

and for ASP.NET modify ApplicationInsights.config file:

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

Yes, the application insights can track sql query. But note that there are some changes in the latest version of application insights nuget package, which makes it does not automatically track sql query.

You can do it via the workaround below.

Assume you're using the .net core web project. Then you need to downgrade the Microsoft.ApplicationInsights.AspNetCore to version 2.12.0.

Here is my test result with version 2.12.0 of that package:

enter image description here

And also, you can use other workarounds, see here for more details.