要确保在Application Insights监视器中显示所有SQL查询,需要在应用程序启动时启用对Application Insights的跟踪,才能开始收集数据。另外,可能需要检查查询是否正确了统计。以下是一些代码示例:
// Enable Application Insights tracking
TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault();
configuration.InstrumentationKey = "your-instrumentation-key";
configuration.EnableRequestTracking = true;
// Check if all SQL queries are correctly captured
var dependencyTelemetry = new DependencyTelemetry
{
Name = "SQL query",
Data = "",
Type = "SQL",
Target = "",
Success = true,
};
telemetryClient.TrackDependency(dependencyTelemetry);
还要考虑使用正确的版本和配置,根据需要启用分析器,并检查是否配置了适当的过滤器。最后需要确认正确的工作,可以观察日志,或使用Application Insights的分析器。