简体   繁体   English

Service Fabric 中的应用程序洞察?

[英]Application Insights in Service Fabric?

I need to add performance logging in a Azure Service Fabric application I'm developing.我需要在我正在开发的 Azure Service Fabric 应用程序中添加性能日志记录。 I've tried to follow the following guide which seems quite straightforward and easy:我试图遵循以下指南,这似乎非常简单明了:

https://github.com/Microsoft/azure-content/blob/master/articles/service-fabric/service-fabric-diagnostics-application-insights-setup.md https://github.com/Microsoft/azure-content/blob/master/articles/service-fabric/service-fabric-diagnostics-application-insights-setup.md

Yet, I'm unable to find the package Microsoft.ServiceFabric.Telemetry.ApplicationInsights on NuGet.但是,我无法在 NuGet 上找到Microsoft.ServiceFabric.Telemetry.ApplicationInsights包。 Since that article is from last year maybe things have changed quite a bit, but I'm not sure whether configuring Insights for aan Azure Service Fabric app is quite different from any ASP.Net app (I can imply from the article that maybe is a bit different).由于那篇文章是去年的,也许情况已经发生了很大变化,但我不确定为 Azure Service Fabric 应用程序配置 Insights 是否与任何 ASP.Net 应用程序有很大不同(我可以从文章中暗示这可能是一个有点不同)。

Can someone point me in the right direction on how to do it properly?有人能指出我正确的方向吗?

Thank you.谢谢。

The NuGet package is located here: https://www.nuget.org/packages/Microsoft.ServiceFabric.Telemetry.ApplicationInsights/ NuGet 包位于此处: https : //www.nuget.org/packages/Microsoft.ServiceFabric.Telemetry.ApplicationInsights/

Make sure to configure your search to include "Prerelease" packages.确保将您的搜索配置为包含“预发行”软件包。

You're likely looking for the updated GitHub repository at https://github.com/Microsoft/ApplicationInsights-ServiceFabric .您可能正在https://github.com/Microsoft/ApplicationInsights-ServiceFabric寻找更新的 GitHub 存储库。 This lists two NuGet packages to use depending on your use case:这列出了根据您的用例使用的两个 NuGet 包:

We did come up with our own integration including support for dependency tracking and Live Metrics Stream.我们确实提出了自己的集成,包括对依赖项跟踪和实时指标流的支持。

Basically what you need to do is manually adding the required dependency and performance collectors of Application Insights to your application like this:基本上,您需要做的是手动将 Application Insights 所需的依赖项和性能收集器添加到您的应用程序中,如下所示:

        var configuration = new TelemetryConfiguration()
        {
            InstrumentationKey = aiKey
        };

        var module = new DependencyTrackingTelemetryModule();
        module.Initialize(configuration);

        QuickPulseTelemetryProcessor processor = null;

        configuration.TelemetryProcessorChainBuilder
            .Use(next =>
            {
                processor = new QuickPulseTelemetryProcessor(next);
                return processor;
            })
            .Build();

        var quickPulse = new QuickPulseTelemetryModule();
        quickPulse.Initialize(configuration);
        quickPulse.RegisterTelemetryProcessor(processor);

Then to log and correlate requests of your frontend services and your backend stateful/stateless services you will need to intercept calls to the SF services based on the directions of this post: How to add message header to the request when using default client of Azure service fabric?然后要记录和关联前端服务和后端有状态/无状态服务的请求,您需要根据这篇文章的说明拦截对 SF 服务的调用: How to add message header to the request when using default client of Azure service面料?

Web Api requests can be logged to Application Insights using some custom Middleware, that is not too hard to write.可以使用一些自定义中间件将 Web Api 请求记录到 Application Insights,这并不难编写。

We have created a code repository that outlines a working example that can be found here at https://github.com/DeHeerSoftware/Azure-Service-Fabric-Logging-And-Monitoring我们创建了一个代码存储库,概述了一个工作示例,可以在https://github.com/DeHeerSoftware/Azure-Service-Fabric-Logging-And-Monitoring找到

It is quite a lot of code to integrate everything so please take a look at the provided repository.集成所有内容需要大量代码,因此请查看提供的存储库。 It will give you a starting point.它会给你一个起点。

实时指标流

依赖追踪

The package can still be installed using Package Manager Console:仍然可以使用包管理器控制台安装包:

Install-Package Microsoft.ServiceFabric.Telemetry.ApplicationInsights
 -Pre -Version 0.3.193-preview2 

However, see the important note "The owner has unlisted this package. This could mean that the package is deprecated or shouldn't be used anymore."但是,请参阅重要说明“所有者已取消列出此软件包。这可能意味着该软件包已弃用或不应再使用。”

https://www.nuget.org/packages/Microsoft.ServiceFabric.Telemetry.ApplicationInsights/ https://www.nuget.org/packages/Microsoft.ServiceFabric.Telemetry.ApplicationInsights/

It looks like it's still very early days on this integration.看起来这种集成还为时过早。 Additionally all it currently does is route ETW events through to App Insights.此外,它目前所做的只是将 ETW 事件路由到 App Insights。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM