简体   繁体   English

您如何将Application Insights集成到Service Fabric中?

[英]How do you integrate Application Insights into Service Fabric?

I currently use Azure Application Insights for logging on all of my Web API and MVC applications. 我目前使用Azure Application Insights登录所有Web API和MVC应用程序。 Obviously the majority of this logging is automatic which is great. 显然,此日志记录的大部分是自动的,这非常好。 For events that I manually want to capture I have implemented a "LoggingUtility" which has methods like "LogError" and "LogInformation" that simply call Trace.TraceError and Trace.TraceInformation (the thinking is that the implementation of logging could be changed in one place in the future). 对于我要手动捕获的事件,我实现了一个“ LoggingUtility”,其中包含诸如“ LogError”和“ LogInformation”之类的方法,它们仅调用Trace.TraceError和Trace.TraceInformation(这种想法是可以将日志记录的实现更改为一个放置在将来)。 The Trace is then captured by Application Insights. 然后,跟踪将被Application Insights捕获。

I have started to develop some Stateful Services in Azure Service Fabric and cannot seem to find a way to use Application Insights. 我已经开始在Azure Service Fabric中开发一些状态服务,但似乎找不到使用应用程序见解的方法。 I have stumbled upon several articles pointing me towards a NuGet package that was in prerelease but has now been removed ( https://www.nuget.org/packages/Microsoft.ServiceFabric.Telemetry.ApplicationInsights/ ). 我偶然发现了几篇文章,指出了我指向预发布但已被删除的NuGet程序包( https://www.nuget.org/packages/Microsoft.ServiceFabric.Telemetry.ApplicationInsights/ )。

Of course the Service Fabric templates generate the "ServiceEventSource" but firstly I cannot see how this would be useful for Application Insights and ideally I want all logging to be done through my "LoggingUtility" class. 当然,Service Fabric模板会生成“ ServiceEventSource”,但首先我看不到它对Application Insights的用处,并且理想情况下,我希望所有日志记录都通过“ LoggingUtility”类完成。

Is it possible to integrate Application Insights into Service Fabric? 是否可以将Application Insights集成到Service Fabric中? If so, can I simply continue using Trace (via my "LoggingUtility" class)? 如果是这样,我是否可以继续使用Trace(通过“ LoggingUtility”类)?

You have two options: 1. Using the Application Insights SDK in your LoggingUtility class to send information directly to AI 2. Using Windows Azure Diagnostics (WAD) to forward Eventsource traces to AI, using the provided EventSource class in the SF project templates. 您有两个选择:1.在LoggingUtility类中使用Application Insights SDK将信息直接发送到AI。2.在SF项目模板中使用提供的EventSource类,使用Windows Azure诊断(WAD)将Eventsource跟踪转发到AI。 That class you can modify to be your LoggingUtility class implementation. 您可以将该类修改为LoggingUtility类的实现。

Considering that you are running your SF cluster in Azure, the second approach is the current recommendation, as Service Fabric system service events are also using Event Tracing. 考虑到您正在Azure中运行SF群集,因此第二种方法是当前建议,因为Service Fabric系统服务事件也正在使用事件跟踪。

For configuring Azure Diagnostics to AI, follow the steps outlined in this article: https://azure.microsoft.com/en-us/blog/azure-diagnostics-integration-with-application-insights/ 要将Azure诊断配置为AI,请按照本文概述的步骤进行操作: https : //azure.microsoft.com/zh-cn/blog/azure-diagnostics-integration-with-application-insights/

Be aware this article targets Cloud Services and VMs, but just use the VM Scale Set for configuring Azure Diagnostics in stead of a VM. 请注意,本文针对的是Cloud Services和VM,但仅使用VM Scale Set代替VM来配置Azure诊断。 That should work. 那应该工作。

The NuGet package is no longer supported: https://social.msdn.microsoft.com/Forums/en-US/f0f1ad78-4d83-48e5-b1da-4a9f0eddb9b2/application-insights-for-service-fabric?forum=AzureServiceFabric 不再支持NuGet软件包: https ://social.msdn.microsoft.com/Forums/zh-CN/f0f1ad78-4d83-48e5-b1da-4a9f0eddb9b2/application-insights-for-service-fabric?forum =AzureServiceFabric

我们使用了新的Microsoft.Extensions.Logging并编写了一个见解记录器-它通过Trace获取服务结构消息,我们还提取了所有未添加的ETW内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Service Fabric 中的应用程序洞察? - Application Insights in Service Fabric? 如何配置.NET Core 2.1服务结构服务以在应用程序洞察中自动使用请求和依赖关系跟踪 - How do I configure a .NET Core 2.1 service fabric service to automatically use request and dependency tracking in application insights 如何在 Azure Service Fabric 应用程序中注入 IHttpClientFactory? - How do I inject IHttpClientFactory in my Azure Service Fabric application? 如何浏览服务结构上的应用程序? - How to browse application on service fabric? 如何在Application Insights中跟踪来自Azure WebJobs的自定义事件? - How do you track custom events from Azure WebJobs in Application Insights? 没有异常对象时的Application Insights TrackException ExceptionTelemetry - Application Insights TrackException ExceptionTelemetry when you do not have an exception object Service Fabric 应用程序部署 - Service Fabric Application deployment 如何在 Service Fabric 应用程序中运行 pythonnet (Keras.Net)? - How do I run pythonnet (Keras.Net) in a Service Fabric Application? 如何结合 Service Fabric Remoting 进行分区 - How to do partitioning in combination with Service Fabric Remoting 如何在服务启动时读取应用洞察密钥 - How to read application insights key during service startup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM