Exercise 1: Using IntelliTrace in Production

In this exercise, you will learn how to deploy and use IntelliTrace in Production to capture trace information for an ASP.NET application.

  1. Log in as Adam. All user passwords are P2ssw0rd.
  2. Launch Internet Explorer and click on the FF Customer Portal button in the favorites bar to load the customer portal for Fabrikam Fiber Support (https://www.fabrikam.com).

    Figure 1

    Fabrikam Fiber customer portal

  3. Select a few of the service tickets from the My Tickets section of the page to view their details until you come across one that indicates that an error occurred retrieving data from the server. This information is ultimately pulled from a database, but there could be any number of reasons for the general error message itself.

    Figure 2

    Error message shown when selecting service ticket

  4. Close Internet Explorer.
  5. Typically, the first step in determining the root cause of an error like this would be to check logs for details and perhaps a stack trace. If that does not provide enough information, and the error is not easily reproduced in a development environment, the development team may end up taking a long time to determine the root cause and fix the problem. Installing Visual Studio or other debugging tools in a production environment may not be an option.
  6. Now let’s look at how to deploy and use IntelliTrace in a production environment to collect historical debugging data. Open a Windows Explorer window and navigate to the root of the C: drive. Note that there are two folders here that were created ahead of time for our use in this lab, c:\IntelliTrace is where the standalone IntelliTrace files are placed and c:\LogFileLocation is where the IntelliTrace files will be written to later on in this lab.

    Figure 3

    Location of IntelliTrace files folder and log file folder

  7. In an Explorer window, right-click on the LogFileLocation folder and select Properties to open the Properties window. We need to make sure that the IIS application pool has permission to use the LogFileLocation folder.
  8. Select the Security tab and then scroll down the existing list of groups and user names to find FabrikamFiber.Extranet.Web. Permissions were added ahead of time in this VM, but in a production environment, you would need to make sure to perform this step yourself.

    Figure 4

    Setting security to enable log files to be written

  9. Press the Escape key to exit out of the properties window.
  10. IntelliTrace can be deployed to a production environment simply by extracting the contents of the IntelliTraceCollection.cab file that ships with Visual Studio 11. This task has also been performed ahead of time in the VM for your convenience, so there is no need for you to perform this step.

    Figure 5

    Extracted contents of IntelliTraceCollection.cab file

    For the purposes of this lab, the production system is the same as our development system, but that will not normally be the case.

  11. Open a PowerShell window and type the following command to import the IntelliTrace PowerShell module:

    Import-Module c:\IntelliTrace\Microsoft.VisualStudio.IntelliTrace.PowerShell.dll

  12. To see the commands provided by IntelliTrace, using the following PowerShell command:

    Get-Command *IntelliTrace*

    Figure 6

    Searching for commands that contain “IntelliTrace”

    Commands are provided to start and stop an IntelliTrace collection, as well as to take checkpoints during collection.

  13. To get help for any of the PowerShell IntelliTrace commands, type something like the following:

    Get-Help Start-IntelliTraceCollection

    Figure 7

    Help screen for the Start-IntelliTraceCollection command

    The REMARKS section from the help listing describes how you can get more detailed examples of command usage.

  14. We are now ready to start IntelliTrace collection. Type the following PowerShell command to start collecting data from the FabrikamFiber.Extranet.Web IIS application pool and store the resulting .iTrace log files in the folder we previously created.

    Start-IntelliTraceCollection "FabrikamFiber.Extranet.Web" c:\IntelliTrace\collection_plan.ASP.NET.trace.xml c:\LogFileLocation

    In the Visual Studio 11, you can hand-edit the collection plan file if you want to make changes. A graphical editor is expected to be provided in a later release.

  15. When asked to confirm, type “Y” and then press the Enter key to continue.

    Figure 8

    Confirming the request to start a collection

  16. Launch Internet Explorer and click on the FF Customer Portal button in the favorites bar to load https://www.fabrikam.com.
  17. IntelliTrace is now setup to gather the debugging data specified in the collection plan configuration file. Select the service tickets to reproduce the error that we saw before. As soon as you see the error, close Internet Explorer.

    Figure 9

    Reproducing the error

  18. Return to the PowerShell window and type the following command to get the current collection status.

    Get-IntelliTraceCollectionStatus -ApplicationPool "FabrikamFiber.Extranet.Web"

    Figure 10

    Collection status

  19. Type the following command to stop gathering IntelliTrace data for the FabrikamFiber.Extranet.Web application pool. Confirm the action when prompted.

    Stop-IntelliTraceCollection "FabrikamFiber.Extranet.Web"

    As an alternative to stopping an IntelliTrace collection, it is also possible to get a copy of the current log by using the Checkpoint-IntelliTraceCollection command. This allows you to look at the data you have captured so far while continuing to collect additional data.

  20. In a real-world scenario, it is at this point that the IntelliTrace file would be sent to a developer or tester for a more detailed look.