{"id":823,"date":"2014-08-14T22:24:19","date_gmt":"2014-08-14T22:24:19","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2014\/08\/14\/application-insights-instrumentation-approaches-for-running-tests\/"},"modified":"2022-05-26T07:55:37","modified_gmt":"2022-05-26T15:55:37","slug":"application-insights-instrumentation-approaches-for-running-tests","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/application-insights-instrumentation-approaches-for-running-tests\/","title":{"rendered":"Application Insights &#8211; instrumentation approaches for running tests"},"content":{"rendered":"<p>[this summer Beckylin Orooji from the University of Central Florida in Orlando studying Computer Science interned with the Application Insights team in the developer division at Microsoft.\u00a0 Below is a blog she authored based on some end to end scenarios she worked on]<\/p>\n<p>In my scenario today I have a shopping website. I have made some changes to the checkout process and want to see if those changes have resulted in more people checking out. I want to make decisions based on the data I receive; depending on my results I will decide whether or not my changes were successful. Now, imagine you have two different versions of your application running either at the same time with the ability to direct some percentage of traffic to each or at different times and you\u2019d like to compare results between them. Below are some suggestions and patterns on how to best structure your telemetry and usage of the Application Insights SDKs so you can answer the questions you have and make informed decisions about which version is more successful for your customers.<\/p>\n<p>**Step 1: Add New Application in Application Insights<br \/>\n**<br \/>\nClick \u2018Add application\u2019 under the OVERVIEW tab.<\/p>\n<p>For a website you should answer as seen in the picture below.<\/p>\n<p><img decoding=\"async\" title=\"clip_image002\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image002\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/08\/0640.clip_image002_thumb_0E689364.png\" width=\"582\" height=\"170\" \/><\/p>\n<p>Follow the instructions generated<\/p>\n<p><img decoding=\"async\" title=\"clip_image002[5]\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image002[5]\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/08\/8816.clip_image0025_thumb_3E926ED8.png\" width=\"586\" height=\"433\" \/><\/p>\n<p>\u00a0<\/p>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<p>**Step 2: Send data to Application Insights **<\/p>\n<p>Visit <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dn614099.aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/dn614099.aspx<\/a> to read more on how to add custom telemetry to your code.<br \/>\nFor my website I wanted to know every time a costumer adds something to their cart and checks out.<br \/>\nBelow you can see an example of logging an event every time a costumer adds something to their cart.<\/p>\n<p><img decoding=\"async\" title=\"clip_image002[8]\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image002[8]\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/08\/7848.clip_image0028_thumb_72C6981E.png\" width=\"625\" height=\"102\" \/><\/p>\n<p>\u00a0<\/p>\n<p>When choosing how to organize your data you can choose different ways. The table below provides a couple different strategies with pros\/cons<\/p>\n<table cellspacing=\"0\" cellpadding=\"0\" width=\"722\" border=\"1\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"217\">\n        \u00a0\n      <\/td>\n<td valign=\"top\" width=\"239\">\n<p>\n          <b>Pros<\/b>\n        <\/p>\n<\/td>\n<td valign=\"top\" width=\"264\">\n<p>\n          <b>Cons<\/b>\n        <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"217\">\n<p>\n          <b>2 Separate Applications<\/b>\n        <\/p>\n<p>\n          Add a new application for each version in Application Insights\n        <\/p>\n<p>\n          Different Component IDs\n        <\/p>\n<\/td>\n<td valign=\"top\" width=\"239\">\n<p>\n          \u2022 Information separated\n        <\/p>\n<p>\n          \u2022 Not cluttered by all the different versions being displayed at the same time\n        <\/p>\n<\/td>\n<td valign=\"top\" width=\"264\">\n<p>\n          \u2022 Have to go through the process of setting up a new application for each version of website\n        <\/p>\n<p>\n          \u2022 Have to navigate through different applications to gather all of the information\n        <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"217\">\n<p>\n          <b>End log event path with version<\/b>\n        <\/p>\n<p>\n          \/\u2026\/\u2026\/Version1\n        <\/p>\n<p>\n          \/\u2026\/\u2026\/Version2\n        <\/p>\n<\/td>\n<td valign=\"top\" width=\"239\">\n<p>\n          \u2022 Able to view every version on the same page in Application Insights\n        <\/p>\n<\/td>\n<td valign=\"top\" width=\"264\">\n<p>\n          \u2022 Have to expand everything to see the version\n        <\/p>\n<p>\n          \u2022 If you have many versions this page in application insights can become very text heavy\n        <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"217\">\n<p>\n          <b>Lead log event path with version<\/b>\n        <\/p>\n<p>\n          Version1\/\u2026\/\u2026\/\n        <\/p>\n<p>\n          Version2\/\u2026\/\u2026\/\n        <\/p>\n<\/td>\n<td valign=\"top\" width=\"239\">\n<p>\n          \u2022 Able to view every version on the same page in Application Insights\n        <\/p>\n<p>\n          \u2022 Gives you total activities\/events for each version\n        <\/p>\n<\/td>\n<td valign=\"top\" width=\"264\">\n<p>\n          \u2022 If you have many versions this page in application insights can become very text heavy\n        <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"217\">\n<p>\n          <b>Enter Version as Parameter<\/b>\n        <\/p>\n<p>\n          \/\u2026\/\u2026\/ {version} {}\n        <\/p>\n<\/td>\n<td valign=\"top\" width=\"239\">\n<p>\n          \u2022 Organize by version without affecting path\n        <\/p>\n<p>\n          \u2022 Can search by version\n        <\/p>\n<p>\n          \u2022 Can view certain graphs based on version when passed as a parameter\n        <\/p>\n<\/td>\n<td valign=\"top\" width=\"264\">\n<p>\n          \u2022 Not able to pin metrics if using this strategy in Visual Studio Online\n        <\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p>**Step 3: View data in Application Insights **<\/p>\n<p>In Application Insights under Usage Features Events you will see your data<\/p>\n<p><img decoding=\"async\" title=\"clip_image002[10]\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image002[10]\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/08\/0508.clip_image00210_thumb_35393A55.png\" width=\"748\" height=\"568\" \/><\/p>\n<p>If you click the expand arrows you will notice the data appears in the path you specified when you logged an event<\/p>\n<p><img decoding=\"async\" title=\"clip_image002[12]\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image002[12]\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/08\/2063.clip_image00212_thumb_0DFEF120.png\" width=\"600\" height=\"307\" \/><\/p>\n<hr \/>\n<hr \/>\n<p>**Step 4: Set Up a Dashboard **<\/p>\n<p>In Overview Dashboards click the green plus sign \u2018+\u2019<br \/>\nYou will be prompted to name your new dashboard and select a template<\/p>\n<p><img decoding=\"async\" title=\"clip_image002[4]\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image002[4]\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/08\/2161.clip_image0024_thumb_429F4D5B.gif\" width=\"651\" height=\"376\" \/><\/p>\n<hr \/>\n<p>After creating your dashboard navigate back to under Usage Features Events<\/p>\n<p>Notice the thumbtack symbol by every line of data (circled in red)<\/p>\n<p>You can click this button and have the data associated with it to appear on your new dashboard<\/p>\n<hr \/>\n<table cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"328\">\n        <a href=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/08\/0028.image_thumb_3709901C.png\"><img decoding=\"async\" title=\"image\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/08\/0028.image_thumb_3709901C.png\" width=\"524\" height=\"338\" \/><\/a>\n      <\/td>\n<\/tr>\n<tr>\n<td>\n        \u00a0\n      <\/td>\n<td>\n        \u00a0\n      <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<hr \/>\n<p>After pinning some of the data you can organize your dashboard.\u00a0\u00a0 Below is a side by side comparison of two different versions of my application<\/p>\n<p><img decoding=\"async\" title=\"clip_image002[16]\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image002[16]\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/08\/1512.clip_image00216_thumb_0FCF46E7.png\" width=\"503\" height=\"266\" \/><\/p>\n<p>You now have a side by side comparison of how each version is being used. Use this data when considering how much traffic should be sent to each version of you application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[this summer Beckylin Orooji from the University of Central Florida in Orlando studying Computer Science interned with the Application Insights team in the developer division at Microsoft.\u00a0 Below is a blog she authored based on some end to end scenarios she worked on] In my scenario today I have a shopping website. I have made [&hellip;]<\/p>\n","protected":false},"author":132,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[224,1],"tags":[],"class_list":["post-823","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-devops"],"acf":[],"blog_post_summary":"<p>[this summer Beckylin Orooji from the University of Central Florida in Orlando studying Computer Science interned with the Application Insights team in the developer division at Microsoft.\u00a0 Below is a blog she authored based on some end to end scenarios she worked on] In my scenario today I have a shopping website. I have made [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/132"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=823"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/823\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}