azureentity-framework-6azure-application-insights.net-4.7.2

How to get the full SQL query in Application Insights


I just watched the video https://www.youtube.com/watch?v=TV1u6UoBRwk and saw the section on End to End transactions. I've used that to track down a SQL query that is taking 1.8 mins.

The query is truncated (probably because EF is generating a super long query).

Is there any way to get the full query from Application Insights? enter image description here


Solution

  • enter image description here

    builder.Services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module, o) => { module.EnableSqlCommandTextInstrumentation = true; });
    
    <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">, 
    <EnableSqlCommandTextInstrumentation>true</EnableSqlCommandTextInstrumentation>
    </Add>
    

    References taken from MSDoc and GitHub.