Diagnosing Issues in Production with IntelliTrace and Visual Studio 11Word格式.docx
《Diagnosing Issues in Production with IntelliTrace and Visual Studio 11Word格式.docx》由会员分享,可在线阅读,更多相关《Diagnosing Issues in Production with IntelliTrace and Visual Studio 11Word格式.docx(12页珍藏版)》请在冰豆网上搜索。
![Diagnosing Issues in Production with IntelliTrace and Visual Studio 11Word格式.docx](https://file1.bdocx.com/fileroot1/2023-1/31/d4576bcb-6c22-4daa-9b39-4b42572e7a97/d4576bcb-6c22-4daa-9b39-4b42572e7a971.gif)
Exercise1:
UsingIntelliTraceinProduction4
Exercise2:
DebuggingwithIntelliTraceFilesfromProduction10
Overview
IntelliTrace–firstreleasedinVisualStudio2010–changedthegamefordebuggingbyallowingdeveloperstostep“backintime”toseehowanapplicationgotintoitscurrentstate.Byexposingeventssuchasfileandregistryaccess,exceptions,andmethodcalls,anIntelliTracefilecanprovideadetailedviewintoapplicationbehavior.Inthislab,youwilllearnhowVisualStudio11willextendthecapabilitiesofIntelliTracebeyondthedevelopmentandtestingorganizationsbyprovidingITadministratorswiththeabilitytocaptureIntelliTracefilesrunningfromproductionservers.Thesefilescanthenbeanalyzedbydeveloperstohelpdiagnoseproductionissues.
Prerequisites
InordertocompletethislabyouwillneedtheVisualStudio11virtualmachineprovidedbyMicrosoft.Formoreinformationonacquiringandusingthisvirtualmachine,pleaseseethisblogpost.
AbouttheFabrikamFiberScenario
Thissetofhands-on-labsusesafictionalcompany,FabrikamFiber,asabackdroptothescenariosyouarelearningabout.FabrikamFiberprovidescabletelevisionandrelatedservicestotheUnitedStates.TheyaregrowingrapidlyandhaveembracedWindowsAzuretoscaletheircustomer-facingwebsitedirectlytoend-userstoallowthemtoself-serviceticketsandtracktechnicians.Theyalsouseanon-premisesASP.NETMVCapplicationfortheircustomerservicerepresentativestoadministercustomerorders.
Inthissetofhands-onlabs,youwilltakepartinanumberofscenariosthatinvolvethedevelopmentandtestingteamatFabrikamFiber.Theteam,whichconsistsof8-10people,hasdecidedtouseVisualStudioapplicationlifecyclemanagementtoolstomanagetheirsourcecode,runtheirbuilds,testtheirwebsites,andplanandtracktheproject.
Exercises
Thishands-onlabincludesthefollowingexercises:
1.UsingIntelliTraceinProduction
2.DebuggingwithIntelliTraceFilesfromProduction
Estimatedtimetocompletethislab:
60minutes.
UsingIntelliTraceinProduction
Inthisexercise,youwilllearnhowtodeployanduseIntelliTraceinProductiontocapturetraceinformationforanASP.NETapplication.
3.LoginasAdam.AlluserpasswordsareP2ssw0rd.
4.LaunchInternetExplorerandclickontheFFCustomerPortalbuttoninthefavoritesbartoloadthecustomerportalforFabrikamFiberSupport().
Figure1
FabrikamFibercustomerportal
5.SelectafewoftheserviceticketsfromtheMyTicketssectionofthepagetoviewtheirdetailsuntilyoucomeacrossonethatindicatesthatanerroroccurredretrievingdatafromtheserver.Thisinformationisultimatelypulledfromadatabase,buttherecouldbeanynumberofreasonsforthegeneralerrormessageitself.
Figure2
Errormessageshownwhenselectingserviceticket
6.CloseInternetExplorer.
7.Typically,thefirststepindeterminingtherootcauseofanerrorlikethiswouldbetochecklogsfordetailsandperhapsastacktrace.Ifthatdoesnotprovideenoughinformation,andtheerrorisnoteasilyreproducedinadevelopmentenvironment,thedevelopmentteammayenduptakingalongtimetodeterminetherootcauseandfixtheproblem.InstallingVisualStudioorotherdebuggingtoolsinaproductionenvironmentmaynotbeanoption.
8.Nowlet’slookathowtodeployanduseIntelliTraceinaproductionenvironmenttocollecthistoricaldebuggingdata.OpenaWindowsExplorerwindowandnavigatetotherootoftheC:
drive.Notethattherearetwofoldersherethatwerecreatedaheadoftimeforouruseinthislab,c:
\IntelliTraceiswherethestandaloneIntelliTracefilesareplacedandc:
\LogFileLocationiswheretheIntelliTracefileswillbewrittentolateroninthislab.
Figure3
LocationofIntelliTracefilesfolderandlogfilefolder
9.InanExplorerwindow,right-clickontheLogFileLocationfolderandselectPropertiestoopenthePropertieswindow.WeneedtomakesurethattheIISapplicationpoolhaspermissiontousetheLogFileLocationfolder.
10.SelecttheSecuritytabandthenscrolldowntheexistinglistofgroupsandusernamestofindFabrikamFiber.Extranet.Web.PermissionswereaddedaheadoftimeinthisVM,butinaproductionenvironment,youwouldneedtomakesuretoperformthisstepyourself.
Figure4
Settingsecuritytoenablelogfilestobewritten
11.PresstheEscapekeytoexitoutofthepropertieswindow.
12.IntelliTracecanbedeployedtoaproductionenvironmentsimplybyextractingthecontentsoftheIntelliTraceCollection.cabfilethatshipswithVisualStudio11.ThistaskhasalsobeenperformedaheadoftimeintheVMforyourconvenience,sothereisnoneedforyoutoperformthisstep.
Figure5
ExtractedcontentsofIntelliTraceCollection.cabfile
Note:
Forthepurposesofthislab,theproductionsystemisthesameasourdevelopmentsystem,butthatwillnotnormallybethecase.
13.OpenaPowerShellwindowandtypethefollowingcommandtoimporttheIntelliTracePowerShellmodule:
Import-Modulec:
\IntelliTrace\Microsoft.VisualStudio.IntelliTrace.PowerShell.dll
14.ToseethecommandsprovidedbyIntelliTrace,usingthefollowingPowerShellcommand:
Get-Command*IntelliTrace*
Figure6
Searchingforcommandsthatcontain“IntelliTrace”
CommandsareprovidedtostartandstopanIntelliTracecollection,aswellastotakecheckpointsduringcollection.
15.TogethelpforanyofthePowerShellIntelliTracecommands,typesomethinglikethefollowing:
Get-HelpStart-IntelliTraceCollection
Figure7
HelpscreenfortheStart-IntelliTraceCollectioncommand
TheREMARKSsectionfromthehelplistingdescribeshowyoucangetmoredetailedexamplesofcommandusage.
16.WearenowreadytostartIntelliTracecollection.TypethefollowingPowerShellcommandtostartcollectingdatafromtheFabrikamFiber.Extranet.WebIISapplicationpoolandstoretheresulting.iTracelogfilesinthefolderwepreviouslycreated.
Start-IntelliTraceCollection"
FabrikamFiber.Extranet.Web"
c:
\IntelliTrace\collection_plan.ASP.NET.trace.xmlc:
\LogFileLocation
IntheVisualStudio11DeveloperPreview,youcanhand-editthecollectionplanfileifyouwanttomakechanges.Agraphicaleditorisexpectedtobeprovidedinalaterrelease.
17.Whenaskedtoconfirm,type“Y”andthenpresstheEnterkeytocontinue.
Figure8
Confirmingtherequesttostartacollection
18.LaunchInternetExplorerandclickontheFFCustomerPortalbuttoninthefavoritesbartoload.
19.IntelliTraceisnowsetuptogatherthedebuggingdataspecifiedinthecollectionplanconfigurationfile.Selecttheserviceticketstoreproducetheerrorthatwesawbefore.Assoonasyouseetheerror,closeInternetExplorer.
Figure9
Reproducingtheerror
20.ReturntothePowerShellwindowandtypethefollowingcommandtogetthecurrentcollectionstatus.
Get-IntelliTraceCollectionStatus-ApplicationPool"
Figure10
Collectionstatus
21.TypethefollowingcommandtostopgatheringIntelliTracedatafortheFabrikamFiber.Extranet.Webapplicationpool.Confirmtheactionwhenprompted.
Stop-IntelliTraceCollection"
AsanalternativetostoppinganIntelliTracecollection,itisalsopossibletogetacopyofthecurrentlogbyusingtheCheckpoint-IntelliTraceCollectioncommand.Thisallowsyoutolookatthedatayouhavecapturedsofarwhilecontinuingtocollectadditionaldata.
22.Inareal-worldscenario,itisatthispointthattheIntelliTracefilewouldbesenttoadeveloperortesterforamoredetailedlook.
DebuggingwithIntelliTraceFilesfromProduction
Inthisexercise,youwillseehowwecanusetheIntelliTracefilethatwasgeneratedonaproductionservertoaidindebuggingtheerrorthatwesawinthepreviousexercise.
23.Returningtoourscenario,let’sassumethatwehavealreadytakenthisIntelliTracefileandtransferredittoadevelopmentmachinethathasVisualStudio11installed.Double-clickontheIntelliTracefiletoloaditinVisualStudio11.
Figure11
LoadingtheIntelliTracefile
24.IntheIntelliTracesummarywindow,scrolldowntotheExceptionDatasection.Hereyoucanseeagridshowingallexceptionsthatoccurred.Bydefault,theyaresortedbymostrecenteventtimetotheoldest.
Figure12
ExceptionDatasectionofIntelliTracesummary
25.SelectthelastSystem.NullReferenceExceptionfoundinthelist,thatisthetechnicallytheoldestorfirstonethatwasthrown,andthenselecttheStartDebuggingbuttontostartanIntelliTracedebuggingsession.
Figure13
Startdebuggingataspecificevent
26.AftertheIntelliTracedebuggingsessionstarts,youwillseethattheIntelliTracepaneisautomaticallyloadedandthelocationincodewheretheexceptionoccurredishighlighted.YounowhavefullaccesstothenormalsuiteofIntelliTracedebuggingfunctionality.
Figure14
Debuggingthethrownexception
27.IntheLocalswindow,notethattheServiceTicket.AssignedTopropertycurrentlyhasanullvalue.ThisexplainswhyreferencingserviceTicket.AssignedTo.FullNameincoderesultedinthenullreferenceexceptionthatwesaw.Atthispoint,wecouldfileabuginTeamFoundationServerandattachtheIntelliTracefiletohelpthedevelopmentteammaketheappropriatefix.
Figure15
Findingrootcauseforexception
Togi