Mastering IntelliTrace in Development and Production

Preview:

DESCRIPTION

A session at the Sela Developer Practice covering IntelliTrace, a powerful feature of Visual Studio Ultimate that can provide historical debugging information collected in development or production environments. IntelliTrace is a hybrid logger-profiler-debugger that can uncover super-difficult bugs by tracing through the history of the application's execution.

Citation preview

© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com

SELA DEVELOPER PRACTICEDecember 15-19, 2013

Mastering IntelliTrace in Development and Production

Sasha Goldshtein @goldshtnCTO, SELA Group blog.sashag.net

IntelliTrace®

Profiler-logger-debugger hybrid“Historical Debugging”Tracks events and method call information at runtimeRecords stack trace, local variables, and custom information for each eventRecords exceptions for later review

Demo

Historical Debugging with IntelliTrace

What Exactly Is Collected?

Method parametersMethod return valuesReference type local variables

For each referenced object, whether or not it was there (but not its contents)

void ReadTweets(string account) { List<Tweet> tweets = GetTweets(account, 10); int count = 3; for (int i = 0; i < count; ++i) DisplayTweet(tweets[i]);}

Customizing The Events Collection

Collecting IntelliTrace Logs

Visual Studio can save logs from every run under IntelliTrace

By default at C:\ProgramData\Microsoft Visual Studio\<VERSION>\TraceDebugging\

IntelliTraceSC.exe launch /cp:plan.xml app.exePowerShell cmdlets for ASP.NET/SharePointMicrosoft Test Manager integrationMicrosoft System Center integration

Demo

Opening IntelliTrace Logs

IntelliTrace and Windows Azure

The only practical way to debug long-standing issues in cloud applications

Demo

Collecting IntelliTrace from Windows Azure

Extending IntelliTrace Events

Add your own events to CollectionPlan.xmlIntelliTrace can generate an event from any method call in your code or framework codeData queries

Declarative event formatting from method callsOnly basic types supported

Declarative Data Query

<DiagnosticEventSpecification> <SettingsName _locID="...">Garbage collection</SettingsName> <Bindings> <Binding> <ModuleSpecificationId>mscorlib</ModuleSpecificationId> <TypeName>System.GC</TypeName> <MethodName>Collect</MethodName> <MethodId>System.GC.Collect(System.Int32):System.Void </MethodId> <ShortDescriptionGC induced</ShortDescription> <LongDescription>GC of gen {0}.</LongDescription> <DataQueries> <DataQuery index="0" type="Int32" query="" /> </DataQueries> </Binding> </Bindings></DiagnosticEventSpecification>

Programmability Handlers

Custom code that formats event informationConsult Microsoft.VisualStudio.DefaultDataQueries.dll for inspiration (undocumented)

Programmable Data Query

<DiagnosticEventSpecification enabled="true"> <CategoryId>gesture</CategoryId> <SettingsName _locID="...">Text Changed</SettingsName> <Bindings> <Binding> <MethodId>DiagnosticControls.DiagnosticTextBox.set_DiagnosticText(System.String):System.Void </MethodId>

<ProgrammableDataQuery>    <ModuleName>WinFormsDataQueries.dll</ModuleName>     <TypeName>DiagnosticTextBoxDataQuery</TypeName>   </ProgrammableDataQuery> </Binding>

</Bindings></DiagnosticEventSpecification>

Programmable Handler

public class DiagnosticTextBoxDQ : IProgrammableDataQuery{  public object[] EntryQuery(object thisArg, object[] args) {    return new object[] {      _nameProperty.GetValue(thisArg, null),      _textProperty.GetValue(thisArg, null) }; }  public object[] ExitQuery(object returnValue) {    return null;  }  public string FormatShortDescription(object[] results) {    return string.Format("Text changed for textbox {0}", results[0].ToString());  } //More methods to format and store the collected data}

Summary

IntelliTrace is super-useful inside Visual Studio while debuggingYou can also collect IntelliTrace data from QA, cloud, and production environmentshttp://msdn.microsoft.com/library/hh398365

You can extend IntelliTrace with your own events

QuestionsSasha Goldshtein @goldshtnCTO, SELA Group blog.sashag.net

Recommended