Application Insights in Service Fabric?

2019-02-27 02:02发布

问题:

I need to add performance logging in a Azure Service Fabric application I'm developing. 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

Yet, I'm unable to find the package Microsoft.ServiceFabric.Telemetry.ApplicationInsights on NuGet. 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).

Can someone point me in the right direction on how to do it properly?

Thank you.

回答1:

The NuGet package is located here: https://www.nuget.org/packages/Microsoft.ServiceFabric.Telemetry.ApplicationInsights/

Make sure to configure your search to include "Prerelease" packages.



回答2:

You're likely looking for the updated GitHub repository at https://github.com/Microsoft/ApplicationInsights-ServiceFabric. This lists two NuGet packages to use depending on your use case:

  • Microsoft.ApplicationInsights.ServiceFabric.Native - Use with native reliable services.
  • Microsoft.ApplicationInsights.ServiceFabric - Use with Guest Executable and Guest container services


回答3:

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:

        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?

Web Api requests can be logged to Application Insights using some custom Middleware, that is not too hard to write.

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

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.



回答4:

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/

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.