lmjwheeler
lmjwheeler

Reputation: 93

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. 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). The Trace is then captured by 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. 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/).

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.

Is it possible to integrate Application Insights into Service Fabric? If so, can I simply continue using Trace (via my "LoggingUtility" class)?

Upvotes: 6

Views: 2192

Answers (2)

user1496062
user1496062

Reputation: 1317

We used the new Microsoft.Extentions.Logging and wrote a insights logger - it gets the service fabric messages via Trace we also pulled out all the ETW stuff it doesnt add much .

Upvotes: 0

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. That class you can modify to be your LoggingUtility class implementation.

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.

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/

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. 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

Upvotes: 2

Related Questions