为什么在 App Insights 上无法追踪到超时错误?

Why is the timeout error untraceable on App Insights?

我们请求从托管在 Azure 应用服务

上的 asp.net Web 应用程序收集超时信息,如下所示

理想情况下,这还包括一种区分方式:

基本上,最终目标是追踪我们不断收到的大量超时警报的根本原因。

基本上,我们能够识别我们获得的一些 issues/alerts 并在应用洞察中追踪它们,但由于某种原因,我们无法在应用洞察中追踪超时

可追踪警报:

Non-traceable 警报:

我考虑过 Kusto 查询,但我不确定创建上述指标的公式是什么。

这是完整的无法追踪的错误供参考:

System.ComponentModel.Win32Exception: The wait operation timed out

Generated: Fri, 19 Nov 2021 13:30:41 GMT

System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at Ideal.Infrastructure.Data.Dapper.SqlMapper.<QueryInternal>d__34`1.MoveNext() in C:\Projects\edgemvc-ideal\Ideal.Infrastructure.Data\Dapper\SqlMapper.cs:line 697
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Ideal.Reporting.DynamicDataService.GetDataWithFilterSingular(String procName, BaseFilterParams filterParams) in C:\Projects\edgemvc-ideal\Ideal.ReportService\DynamicDataService.cs:line 28
at Ideal.Reporting.ReportingService.PracticeBreakoutReportPro(String section, BaseFilterParams filters, String schema) in C:\Projects\edgemvc-ideal\Ideal.ReportService\ReportingService.cs:line 248
at Ideal.API.Controllers.ReportController.PracticeBreakoutSectionPro(FilterParams filters, String descriptionId, String section) in C:\Projects\edgemvc-ideal\Ideal.API\Controllers\ReportController\ReportController.cs:line 81
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
ClientConnectionId:9963f70a-f829-4b28-9655-4e256156f4bd
Error Number:-2,State:0,Class:11

编辑

我已尝试根据建议在 Log Analytics 中查找异常,但仍然无法追踪:

我也无法在我的特定应用服务的 Application Insights 下的 Performance/Failure 选项卡中找到其中一些超时。

然而,在我的前端实现 Application Insights SDK (Javascript) 之后:

  • 我想我可以使用 Log Analytics 为我的应用程序中的每个页面找到它们:

  • pageViews
    | where duration > 25000 and client_Type == "Browser"
    | sort by timestamp, count_sum
    

    其中 25000 等于 25 秒,这是我们超时的阈值。

  • 似乎在requeststable中自动跟踪后端请求,因此不需要在前端进行额外的实现:

    requests
    | where duration > 25000
    | summarize count_sum = count() by bin(timestamp,1d), operation_Name, name
    | sort by timestamp, count_sum
    

免责声明:我不是 100% 确定正确性,但至少它对我有所帮助。我觉得 Application Insights 的文档有点复杂。