我们最近通过ApplicationInsights.OwinExtensions为使用owin的应用程序启用了请求跟踪。我们还使用Microsoft.ApplicationInsights.ServiceFabric.Native启用了服务结构清除细节。启用此功能后,我们将在遥测中看到许多与任务取消有关的异常 ApplicationInsights.OwinExtensions.HttpRequestTrackingMiddleware + d__4.MoveNext上的System.Threading.Tasks.TaskCanceledException 从本地进行测试时没有面对这个问题。将代码部署到Service Fabric之后,这些异常弹出。
记录请求:
public static class Startup
{
public static void ConfigureApp(IAppBuilder appBuilder)
{
appBuilder.UseApplicationInsights();
//Rest of the code
}
}
记录服务结构详细信息:
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
FabricTelemetryInitializerExtension.SetServiceCallContext(this.Context);
return new ServiceInstanceListener[]
{
new ServiceInstanceListener(serviceContext => new
OwinCommunicationListener(Startup.ConfigureApp, serviceContext, ServiceEventSource.Current, "endpoint"))
};
}