{"id":13355,"date":"2017-07-05T20:21:00","date_gmt":"2017-07-05T20:21:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/premier_developer\/?p=13355"},"modified":"2019-03-05T12:51:19","modified_gmt":"2019-03-05T19:51:19","slug":"using-perfview-with-azure-service-fabric-event-source-messages","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/using-perfview-with-azure-service-fabric-event-source-messages\/","title":{"rendered":"Using PerfView with Azure Service Fabric Event Source Messages"},"content":{"rendered":"<p>This post is provided by Senior App Dev Manager, <a href=\"https:\/\/www.linkedin.com\/in\/mheisenberg\/\">Mark Eisenberg<\/a>, who spotlights the use of PerfView as a handy tool for debugging Azure Service Fabric applications.<\/p>\n<hr \/>\n<p>The Service Fabric tooling provides a Diagnostic Events viewer for Visual Studio that displays Event Trace for Windows (ETW) messages generated by the event sources provided with the SDK, ServiceEventSource and ActorEventSource. When working on a project with eight actors, two of which had hundreds of instantiations, it did not take long to swamp the built-in view. It topped out at 5000 messages and then began dropping the oldest messages. In addition, it could not keep up with the message rate.<\/p>\n<p>One thing I learned quickly when debugging an actor-based application, as is the case with any highly concurrent architecture, traditional debuggers prove to be not useful. And the limitations in the Diagnostic Events viewer also quickly made it not helpful. A full-length run of the system generated on the order of 50000 messages in about a minute and half. But I had to see what I had to see and I was assured that the problem was with the viewer and the not the ETW system.<\/p>\n<p>A wise man pointed me to PerfView which despite my advanced years, I had never used. The challenges I ran in to are likely laughable to those people who have had opportunity to troubleshoot real-time problems in Windows-based systems, but this post is for everyone else. BTW, there are several other ways to capture ETW traces when the cluster is running on a real cluster of machines. This article is about using a cluster on a developer\u2019s own machine.<\/p>\n<p>Step 1 \u2013 download PerfView from <a href=\"https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=28567\">Download PerfView<\/a>.<\/p>\n<blockquote><p>It\u2019s standalone so just put the exe someplace convenient.<\/p><\/blockquote>\n<p>Step 2 \u2013 Make a note of the name(s) of your event source(s)<\/p>\n<blockquote><p>Open up each of the ServiceEventSource.cs and ActorEventSource.cs files and make a note of the event source name:<\/p>\n<pre class=\"lang:default decode:true \">[EventSource(Name = \"Incelligence-TestWebService-TestWebApi\")]\r\ninternal sealed class ServiceEventSource : EventSource\r\n[EventSource(Name = \"Incelligence-BuildIPMLApplication-Ipml\")]\r\ninternal sealed class ActorEventSource : EventSource\r\n<\/pre>\n<p>Another way to accomplish this is by running your app with the Diagnostics Events viewer and looking for the \u201cProviderName\u201d in the JSON for the events in which you are interested:<\/p><\/blockquote>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv1.png\"><img decoding=\"async\" title=\"pv1\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv1_thumb.png\" alt=\"pv1\" width=\"644\" height=\"369\" border=\"0\" \/><\/a><\/p>\n<p>Step 3 \u2013 Fire up PerfView<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv2.png\"><img decoding=\"async\" title=\"pv2\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv2_thumb.png\" alt=\"pv2\" width=\"644\" height=\"346\" border=\"0\" \/><\/a><\/p>\n<p>Step 4 \u2013 Collect-&gt;Collect or Alt-C and expand the advanced options<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv3.png\"><img decoding=\"async\" title=\"pv3\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv3_thumb.png\" alt=\"pv3\" width=\"644\" height=\"358\" border=\"0\" \/><\/a><\/p>\n<p>Step 5 \u2013 Untick all of the provider boxes and fill in the Additional Providers field with the Service Fabric providers you need such as \u201c*Microsoft-ServiceFabric-Actors\u201d and \u201c*Incelligence-BuildIPMLApplication-Helpers\u201d. Don\u2019t forget the \u201c*\u201d. It is important. Don\u2019t know why, but nothing happens if you leave it out.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv4.png\"><img decoding=\"async\" title=\"pv4\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv4_thumb.png\" alt=\"pv4\" width=\"644\" height=\"359\" border=\"0\" \/><\/a><\/p>\n<p>Step 6 \u2013 Click \u201cStart Collection\u201d<\/p>\n<p>Step 7 \u2013 Run your application<\/p>\n<p>Step 8 \u2013 Click \u201cStop Collection\u201d<\/p>\n<p>Step 9 \u2013 Wait until the processing phase completes which will take a while which results in this:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv5.png\"><img decoding=\"async\" title=\"pv5\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv5_thumb.png\" alt=\"pv5\" width=\"326\" height=\"484\" border=\"0\" \/><\/a><\/p>\n<p>Step 10 \u2013 Double-click on Events. Couple of things to note here. The default maximum number of records return is 10000. In the screenshot below I have set it to 50000 and this filter returned 81600 as shown at the bottom of the window. You can select multiple Event Types (I have two selected) and then hit Update. I have also set a filter to only show the message column. Depending on what you are looking for the Text Filter can be invaluable.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv6.png\"><img decoding=\"async\" title=\"pv6\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/31\/2019\/04\/pv6_thumb.png\" alt=\"pv6\" width=\"644\" height=\"410\" border=\"0\" \/><\/a><\/p>\n<p>Summary \u2013 The PerfView tool will reveal everything a developer needs to know about long running Service Fabric applications. It will catch all log messages where the integrated Diagnostics Event viewer can lose messages when the message rate goes to a high level. The developer needs to make sure they properly instrument their code, but if done properly problems cannot stay hidden for long.<\/p>\n<p>Epilogue \u2013 I have not run this application in a couple of months and the Service Fabric has been updated since then. Previously, as I mentioned in the introduction, a run would generate on the order of 50000 messages. This run took almost 15 minutes, hit over 700000 records and 9000 ActorMethodThrewException that did not used to be there. Looks like I will I have use what I just wrote about to ferret out whatever has cropped up.<\/p>\n<hr \/>\n<p><a href=\"https:\/\/blogs.msdn.com\/b\/premier_developer\/archive\/2014\/09\/15\/welcome.aspx\"><strong>Premier Support for Developers<\/strong><\/a> provides strategic technology guidance, critical support coverage, and a range of essential services to help teams optimize development lifecycles and improve software quality.\u00a0 Contact your Application Development Manager (ADM) or <a href=\"https:\/\/blogs.msdn.microsoft.com\/premier_developer\/contact-us\/\">email us<\/a><b><\/b> to learn more about what we can do for you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is provided by Senior App Dev Manager, Mark Eisenberg, who spotlights the use of PerfView as a handy tool for debugging Azure Service Fabric applications. The Service Fabric tooling provides a Diagnostic Events viewer for Visual Studio that displays Event Trace for Windows (ETW) messages generated by the event sources provided with the [&hellip;]<\/p>\n","protected":false},"author":582,"featured_media":37840,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[25],"tags":[24,31,3],"class_list":["post-13355","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","tag-azure","tag-service-fabric","tag-team"],"acf":[],"blog_post_summary":"<p>This post is provided by Senior App Dev Manager, Mark Eisenberg, who spotlights the use of PerfView as a handy tool for debugging Azure Service Fabric applications. The Service Fabric tooling provides a Diagnostic Events viewer for Visual Studio that displays Event Trace for Windows (ETW) messages generated by the event sources provided with the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/13355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=13355"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/13355\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/37840"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=13355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=13355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=13355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}