jon*_*ers 9 .net c# asp.net-web-api azure-service-fabric
现在我们的ASF集群正在运行:
我们正在尝试应用见解,我也喜欢他们的文档设置未处理的错误跟踪这里有我们的Web API项目.
问题是,我想要我们的Actor项目.
在Actor中是否存在捕获未处理错误的全局位置?我知道它是新的,也许这就是为什么我找不到这方面的文档.
现在我在每个actor方法中都这样做,但似乎不是一个很好的解决方案:
public async Task DoStuff()
{
try
{
//Do all my stuff
}
catch (Exception exc)
{
//Send to Windows Event Source
ActorEventSource.Current.ActorMessage(this, "Unhandled error in {0}: {1}", nameof(DoStuff), exc);
//Send to Application Insights
new TelemetryClient().TrackException(exc);
throw exc;
}
}
Run Code Online (Sandbox Code Playgroud)
你有几个选择:
Actor有一个内置的ETW提供者(Microsoft-ServiceFabric-Actors),它有一个ActorMethodThrewException事件.你可以:
EventListener该类来监听进程中的事件并将其转发到App Insights(稍微不那么可靠,但更简单)使用自定义ActorServiceRemotingDispatcher,它是负责向actor调度操作的类
class CustomActorServiceRemotingDispatcher : ActorServiceRemotingDispatcher
{
public CustomActorServiceRemotingDispatcher(ActorService actorService) : base(actorService)
{
}
public override async Task<byte[]> RequestResponseAsync(IServiceRemotingRequestContext requestContext, ServiceRemotingMessageHeaders messageHeaders,
byte[] requestBodyBytes)
{
try
{
LogServiceMethodStart(...);
result = await base.RequestResponseAsync(requestContext, messageHeaders, requestBodyBytes).ConfigureAwait(false);
LogServiceMethodStop(...);
return result;
}
catch (Exception exception)
{
LogServiceMethodException(...);
throw;
}
}
}
Run Code Online (Sandbox Code Playgroud)
要使用此类,您需要创建自定义ActorService类并覆盖该CreateServiceReplicaListeners方法.请注意,这将覆盖ActorRemotingProviderAttribute您可能正在使用的任何内容.
附注:
IServiceRemotingClientFactory来添加它们)ServiceRemotingDispatcher该类)| 归档时间: |
|
| 查看次数: |
2074 次 |
| 最近记录: |