Mastering IntelliTrace in Development and Production

16
© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com SELA DEVELOPER PRACTICE December 15-19, 2013 Mastering IntelliTrace in Development and Production Sasha Goldshtein @goldshtn CTO, SELA Group blog.sashag.net

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.

Transcript of Mastering IntelliTrace in Development and Production

Page 1: Mastering IntelliTrace in Development and Production

© 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

Page 2: Mastering IntelliTrace in Development and Production

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

Page 3: Mastering IntelliTrace in Development and Production

Demo

Historical Debugging with IntelliTrace

Page 4: Mastering IntelliTrace in Development and Production

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]);}

Page 5: Mastering IntelliTrace in Development and Production

Customizing The Events Collection

Page 6: Mastering IntelliTrace in Development and Production

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

Page 7: Mastering IntelliTrace in Development and Production

Demo

Opening IntelliTrace Logs

Page 8: Mastering IntelliTrace in Development and Production

IntelliTrace and Windows Azure

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

Page 9: Mastering IntelliTrace in Development and Production

Demo

Collecting IntelliTrace from Windows Azure

Page 10: Mastering IntelliTrace in Development and Production

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

Page 11: Mastering IntelliTrace in Development and Production

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>

Page 12: Mastering IntelliTrace in Development and Production

Programmability Handlers

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

Page 13: Mastering IntelliTrace in Development and Production

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>

Page 14: Mastering IntelliTrace in Development and Production

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}

Page 15: Mastering IntelliTrace in Development and Production

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

Page 16: Mastering IntelliTrace in Development and Production

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