Short, Self Contained, Correct (Compilable), Example

Hi all

Frequently I get emails from people looking for my help with some BizTalk challenge
they are facing. Some times I just get a zipped version of a project containing schemas
and other artifacts that don’t even have anything to do with the issue – it was just
easier to send the entire thing and hope that I can figure it all out.

So here comes a plea from me to all you people looking for help: Please, when you
send someone an email asking for help, prepare an SSCCE (See more here: http://sscce.org/).

I have plenty of things to look at, so if you take the time to prepare an SSCCE the
chances of me helping you increases by a multitude of 10 🙂

Thanks!



eliasen

Management Tasks for BizTalk CAT Instrumentation Framework – Fully Explained

The following post is intended to drill down into most common administrative tasks involved in the ETW event trace session management, specifically, as it relates to getting the true value of the BizTalk CAT Instrumentation Framework by being able to extract data out of the instrumented BizTalk application code into traditional human-readable trace log file.

Event Trace Management Application Landscape

The Event Tracing for Windows (ETW) infrastructure provides the ability to start and stop event tracing sessions, monitor their status, configure a variety of logging settings such as buffer size, flush interval, stop conditions and more. The majority of the administrative tasks are available from both the GUI and the command-line interface to suit the needs and preferences of different IT persona types.

In addition to using the Reliability and Performance Monitor, the application developers and technical teams have access to other system tools and scripts helping automate many aspects of event trace management:

  • Logman creates and manages Event Trace Session and Performance logs and supports many functions of Performance Monitor from the command line.
  • WEvtUtil enables to retrieve information about event logs and publishers, install and uninstall event manifests, run queries, export, archive, and clear logs.
  • Tracelog starts, stops, or enables trace logging.
  • Tracefmt formats and displays trace messages from an event trace log file or a real-time trace session.

The BizTalk CAT Instrumentation Framework simplifies the use of the above tools by providing 2 easy-to-use scripts with a minimum of command-line parameters. These scripts can be found in the TracingTools folder and are intended to address the following requirements:

  • StartTrace.cmd provides the ability to start an ETW event trace session either for the entire instrumented BizTalk solution, its selected component types or individually instrumented classes. This script is nothing more than just a wrapper for the Tracelog tool from the Windows Resource Kit.
  • StopTrace.cmd carries the responsibility for stopping the ETW event trace sessions and converting a binary trace log file into human-readable format. This script relies on Tracelog and Tracefmt tools to flush, stop and apply formatting to the trace logs.

The next section is intended to clarify how the above administrative scripts map to various management scenarios.

Event Trace Management Tasks

Once deployed and launched, a well instrumented BizTalk application will be ready to emit a number of events related to the application’s behavior, internal state, execution scope durations, runtime exceptions and everything else that the application developers decided to include into the instrumentation context. The top management tasks involved into capturing, filtering and persisting the instrumented events can be summarized as follows.

Starting Event Trace Sessions

To start an event tracing session for the entire instrumented BizTalk application, run StartTrace.cmd using one of following commands depending on the trace level required (all/high/medium/low). Note that the log file name specified after –log parameter can be any name but should not contain whitespaces.

: All trace events (Info, Details, Warning, Error, In, Out, Start Scope, End Scope)
StartTrace -log BtsAppAllEvents -level all

: Limited trace events (Info, Warning, Error)
StartTrace -log BtsAppCoreEvents -level high

: Trace events indicating unexpected behavior (Warning, Error)
StartTrace -log BtsAppUnexpectedEvents -level medium

: Trace events related to runtime exceptions (Error)
StartTrace -log BtsAppExceptions -level low

To start an event tracing session for a specific type of application components, run StartTrace.cmd using one of following commands depending on the component type and trace level required:

: Start trace for all instrumented pipeline components
StartTrace -log PipelineComponentsAllEvents -level all -component Pipeline

: Start trace for all instrumented orchestrations
StartTrace -log OrchestrationsAllEvents -level all -component Workflow

: Start trace for all instrumented data access components
StartTrace -log DataAccessComponentsAllEvents -level all -component DataAccess

: Start trace for all instrumented maps or custom transform code
StartTrace -log MapsAllEvents -level all -component Transform

: Start trace for all instrumented Web/WCF services or service proxies
StartTrace -log WCFServicesAllEvents -level all -component Service

: Start trace for all instrumented business rules
StartTrace -log BusinessRulesAllEvents -level all -component Rules

: Start trace for all instrumented BAM activities
StartTrace -log BAMActivitiesAllEvents -level all -component Tracking

: Start trace for all instrumented custom .NET components
StartTrace -log CustomComponentsAllEvents -level all -component Custom

To start an event tracing session for individually instrumented application components, the component’s Guid attribute value must be provided in the command line as per the following examples:

: Start trace to capture all events for instrumented HL7Disassembler component
StartTrace -log HL7DasmFullTrace -level all -component Custom -guid 0EC4A54D-6B97-47C1-9118-A2BF8B4E7595

: Start trace to capture errors in instrumented HL7Disassembler component
StartTrace -log HL7DasmErrorTrace -level low -component Custom -guid 0EC4A54D-6B97-47C1-9118-A2BF8B4E7595

Monitoring Event Trace Sessions

After an event tracing session is started, it will remain running until it is manually stopped, a stop condition is encountered or host is rebooted. To query the present status of the event tracing sessions, one of the following approaches can be used.

To find out the event tracing session status from the command line, run the Logman utility using the following syntax:

: Lists all event tracing sessions configured on the local machine
Logman query -ets

: Lists all event tracing sessions with a name matching the specified pattern
Logman query -ets | find "AllEvents"

To find out the event tracing session status from the GUI, open Reliability and Performance Monitor and navigate to the Event Trace Sessions section.

Stopping Event Trace Sessions

To stop a running event trace session, the target tools differ depending on whether or not the trace session must be temporarily suspended or terminated with no intent to resume. Consequently, one of the following approaches can be used.

To stop an event tracing session from the command line, run StopTrace.cmd passing the original name of the trace log without file extension:

: Stop trace for all instrumented pipeline components
StopTrace -log PipelineComponentsAllEvents

: Stop trace for all instrumented orchestrations
StopTrace -log OrchestrationsAllEvents

: Stop trace for all instrumented data access components
StopTrace -log DataAccessComponentsAllEvents

: Stop trace for all instrumented maps or custom transform code
StopTrace -log MapsAllEvents

: Stop trace for all instrumented Web/WCF services or service proxies
StopTrace -log WCFServicesAllEvents

: Stop trace for all instrumented business rules
StopTrace -log BusinessRulesAllEvents

: Stop trace for all instrumented BAM activities
StopTrace -log BAMActivitiesAllEvents

: Stop trace for all instrumented custom .NET components
StopTrace -log CustomComponentsAllEvents

Note that StopTrace.cmd will also convert the binary trace log into text-based format using the Tracefmt tool. Depending on the log size and disk IO performance, this operation can take a few minutes.

To temporarily suspend an event tracing session from the command line without producing a text-based log file, run the Logman utility using the following syntax:

: Stop event tracing sessions all instrumented pipeline components, do not convert log into text file
Logman stop PipelineComponentsAllEvents -ets

To temporarily suspend the event tracing session from the GUI, open Reliability and Performance Monitor, navigate to the Event Trace Sessions section, right-click on the target event tracing session and select Stop from the context menu:

Configuring Event Trace Sessions

The default configuration of the ETW event trace sessions created by StartTrace.cmd can be attributed as follows:

  • Buffer Size: 128K
  • Maximum Buffers: 100
  • Log Mode: Circular
  • Maximum Log Size: 1000MB
  • Flush Time: Not Set
  • Clock Type: Performance
  • Stream Mode: File
  • Pre-allocate File Space: No

Should the default configuration be found insufficient and need modifications, the script can be updated to include the desired configuration settings. The new settings must be specified in the following line in StartTrace.cmd:

"%TraceLogTool%" -cir 1000 -b 128 -max 100 -start %TraceLogName% -flags %TraceLevel% -f %TraceLogFileName% -guid #%TraceComponentGUID%

Note that all commands shown in blue will not require any modification. Below are the summary of command line parameters supported by the Tracelog tool:

Usage: tracelog [actions] [options] | [-h | -help | -?]

actions:
-start   [LoggerName] Starts up the [LoggerName] trace session
-stop    [LoggerName] Stops the [LoggerName] trace session
-update  [LoggerName] Updates the [LoggerName] trace session
-enable  [LoggerName] Enables providers for the [LoggerName] session
-disable [LoggerName] Disables providers for the [LoggerName] session
-flush   [LoggerName] Flushes the [LoggerName] active buffers
-remove  GlobalLogger Removes registry keys that activate GlobalLogger
-enumguid             Enumerate Registered Trace Guids
-q       [LoggerName] Query status of [LoggerName] trace session
-l                    List all trace sessions
-x                    Stops all active trace sessions

options:
-b   <n>              Sets buffer size to <n> Kbytes
-min <n>              Sets minimum buffers
-max <n>              Sets maximum buffers
-f <name>             Log to file <name>
-append               Append to file
-prealloc             Pre-allocate
-seq <n>              Sequential logfile of up to n Mbytes
-cir <n>              Circular logfile of n Mbytes
-newfile <n>          Log to a new file after every n Mbytes
-ft <n>               Set flush timer to n seconds
-paged                Use pageable memory for buffers
-noprocess            Disable Process Start/End tracing
-nothread             Disable Thread Start/End tracing
-nodisk               Disable Disk I/O tracing
-nonet                Disable Network TCP/IP tracing
-fio                  Enable file I/O tracing
-pf                   Enable page faults tracing
-hf                   Enable hard faults tracing
-img                  Enable image load tracing
-cm                   Enable registry calls tracing
-um                   Enable Process Private tracing
-guid <file>          Start tracing for providers in file
-rt                   Enable tracing in real time mode
-kd                   Enable tracing in kernel debugger
-age <n>              Modify aging decay time to n minutes
-level <n>            Enable Level passed to the providers
-flag <n>             Enable Flags passed to the providers
-eflag <n> <flag...>  Enable flags (several) to providers
-ls                   Generate Local Sequence Numbers
-gs                   Generate Global Squence Numbers
-heap                 Use this for Heap Guid
-critsec              Use this for CritSec Guid
-pids <n> <pid1... > Tracing for Heap and CritSec for different process

For more information on the related topic, please visit the following resources:

My VS 2010 and ASP.NET 4 Talks Online

The past 7 years I’ve done an annual all day event in Arizona – organized by the most excellent Scott Cate (who always does a phenomenal job organizing the event and making it a great one). Earlier this month I visited and presented 4+ hours of content covering VS 2010, ASP.NET 4 and ASP.NET MVC 2. The talks are demo-heavy and show off a ton of new features.

NextSlide.com – a .NET shop local to Arizona who has a great product for sharing presentations – volunteered to record the talks and publish them for free using their online presentation tool.  The recordings they did turned out really, really great – and their online player (which combines slides + camera of me + demos in one experience) is awesome.  Below you can watch the first two segments of my event – which cover VS 2010 and ASP.NET 4 – for free online using the NextSlide.com player experience.  I’ll post a link to my ASP.NET MVC 2 segment a little later in a separate blog post. 

If you’ve never seen me present these talks before and are interested in VS 2010 and .NET 4 content then I’d recommend checking them out – as these recordings do a really good job capturing them.

Part 1 – VS 2010

This is a 49 minute segment that starts the event and covers a bunch of the new improvements in VS 2010.  You can launch the presentation directly here or watch it inline below.  You can download powerpoint versions of my slides here.

Part 2- ASP.NET 4

This 61 minute segment comes next and drills into some of the framework improvements with ASP.NET 4.  It also goes further on some of the web specific tooling improvements in VS 2010 – and towards the end demonstrates some of the great new end-to-end web deployment features provided with VS 2010 (which work for both ASP.NET Web Forms and ASP.NET MVC applications).

You can launch the presentation directly here or watch it inline below:

Learning More about VS 2010 and ASP.NET 4

I’ve been working on a series of blog post about VS 2010 and .NET 4.  Many of the features I covered in my two talks above are described in more detail in posts within the series.  You can read all of them here. I’ll be continuing adding to the series via my blog, so stay tuned for more in-depth posts about a bunch more new features.

Hope this helps,

Scott

P.S. People often ask whether they can re-use the slides+demos I use in my talks for talks of their own.  The answer to this is always absolutely! No need to ask permission. Feel free to re-use all of my slides for talks of your own.

P.P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu

See you at TechEd North America 2010 in New Orleans?

I’m really looking forward to presenting at TechEd North America 2010 on June 9 2010, and am honored to be co-presenting with John deVadoss (Microsoft, Director, Patterns and Practices) and Christoph Schittko (Microsoft, Global Application Strategist). John and I worked together on the SOA-Manifesto working group, Christoph and I have known each other for years, and we are all co-authors of “SOA with .NET and Windows Azure”, which will also be launching at TechEd (more on this later).

We will be presenting session ASI202 on Wednesday morning, “Real-World SOA with Microsoft .NET and Windows Azure”.

Although I’m late posting this, we as a team have been working VERY hard on this. It should be really good/informative, please join us if you’re going to be there.