异常不会显示在请求详细信息中,但会显示在 Application Insights 中的服务器异常下
Exceptions are not shown in Request details but under Server Exceptions in Application Insights
当在我们的系统中执行 Web.Api 控制器方法期间发生异常时,请求将作为失败发送到 Application Insights,我们将异常发送到 Application Insights telemetry.TrackException(actionExecutedContext.Exception);
行为:
- 请求显示为失败 URL 和详细信息中的一些其他数据
- 异常显示在服务器异常下,堆栈跟踪显示在详细信息中。
然而,当查看失败请求的详细信息时(由于服务器异常),Exception 部分不显示相关的异常 - 只是默认的 了解如何跟踪失败请求的异常情况。
在查看 Visual Studio 2017 内发送到 Application Insights 的内容时,我发现异常和请求是相关的(相同的操作 ID)。
但它在前往详细信息页面的途中丢失了。
我们将 ASP.NET WebApi 与 OWIN、默认 Application Insights 安装(nuget 包)和 applicationinsights-owinextensions(包括此处描述的设置 OWIN 扩展的步骤)一起使用。
我认为 不适用,因为数据在 Visual Studio AppInsights Viewer 中显示为相关,并且在单击 Show telemetry for: this operation 时在 AppInsights 中异常的详细信息视图中。
可能相关:
Application Insights 显示 2 个失败请求。第一个显示 HTTP 方法(例如 GET),第二个缺少 HTTP 方法并且持续时间稍长。
感谢提示:-)
由于您正在使用 applicationinsights-owinextensions,我检查了 OperationIdTelemetryInitializer that is used to initialize operation id. I believe the reason you're not seeing telemetry linked correctly on detail blades is that this code is not setting operation.parentId field. To verify whether this is correct you can examine the payload sent to check whether parent.id field is set. The initializer that we are shipping in the officially supported .NET SDK sets operation.id, as well as operation.parentId 的代码。
所以我的建议是,一旦你确认确实没有设置 parentId,要么修复 owin-extensions 中使用的 OperationIdTelemetryInitializer 以便它开始设置 parentId,要么在 ApplicationInsights.config 中将其替换为你的定制。后一种方法可以很容易地证实这一理论。
解决方案是从 application insights 配置文件中删除 Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer
。
此初始化程序妨碍了 applicationinsights-owinextensions nuget 包中的初始化程序。
当在我们的系统中执行 Web.Api 控制器方法期间发生异常时,请求将作为失败发送到 Application Insights,我们将异常发送到 Application Insights telemetry.TrackException(actionExecutedContext.Exception);
行为:
- 请求显示为失败 URL 和详细信息中的一些其他数据
- 异常显示在服务器异常下,堆栈跟踪显示在详细信息中。
然而,当查看失败请求的详细信息时(由于服务器异常),Exception 部分不显示相关的异常 - 只是默认的 了解如何跟踪失败请求的异常情况。
在查看 Visual Studio 2017 内发送到 Application Insights 的内容时,我发现异常和请求是相关的(相同的操作 ID)。
但它在前往详细信息页面的途中丢失了。
我们将 ASP.NET WebApi 与 OWIN、默认 Application Insights 安装(nuget 包)和 applicationinsights-owinextensions(包括此处描述的设置 OWIN 扩展的步骤)一起使用。
我认为
可能相关: Application Insights 显示 2 个失败请求。第一个显示 HTTP 方法(例如 GET),第二个缺少 HTTP 方法并且持续时间稍长。
感谢提示:-)
由于您正在使用 applicationinsights-owinextensions,我检查了 OperationIdTelemetryInitializer that is used to initialize operation id. I believe the reason you're not seeing telemetry linked correctly on detail blades is that this code is not setting operation.parentId field. To verify whether this is correct you can examine the payload sent to check whether parent.id field is set. The initializer that we are shipping in the officially supported .NET SDK sets operation.id, as well as operation.parentId 的代码。
所以我的建议是,一旦你确认确实没有设置 parentId,要么修复 owin-extensions 中使用的 OperationIdTelemetryInitializer 以便它开始设置 parentId,要么在 ApplicationInsights.config 中将其替换为你的定制。后一种方法可以很容易地证实这一理论。
解决方案是从 application insights 配置文件中删除 Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer
。
此初始化程序妨碍了 applicationinsights-owinextensions nuget 包中的初始化程序。