In this blog post, we will take a look at adding instrumentation code into the USD custom hosted controls. When developing custom hosted controls for USD, it’s important to add the ability to debug, troubleshoot and monitor the performance or behaviour of the custom code.

During unit testing, we can use the ‘Attach to Process’ debugging feature in Visual Studio, but when the USD solution is rolled out to ‘System Test’ or ‘Acceptance’ environments, attaching to USD process is not an option.

Writing Tracing Information

The .NET Trace class of System.Diagnostics namespace has to be used to perform instrumentation in USD. For example, the following code snippet shows how tracing to be implemented in custom hosted control’s codebase.

custom hosted control instrumentation

 

The custom hosted control codebase should have enough Trace.WriteLine statements for effective monitoring, debugging and troubleshooting.

Instrumentation helps in the monitoring, logging and troubleshooting the following scenarios

  1. Integration with 3rd party web services
  2. Integration with ‘Line of Business’ application or web services
  3. Computer Telephony Integrations (CTI) messages
  4. Code execution flow
  5. State of various memory objects

Viewing tracing information

The ‘Debugger’ helps to view the instrumentation added into the custom hosted controls. To launch the Debugger, please select the ‘Debug’ option from the menu available at the top right corner of USD.

custom-hosted-control-instrumentation-3

The live monitoring of Trace.WriteLine information can be seen on the ‘Debug Output’ tab of the ‘Debugger’ as shown in the image below. Ensure to start the Debugger at an appropriate time to view all the traced information. Preferably launch the ‘Debugger’ as soon as USD is ready.

debug-output

 

Instrumentation in USD improves the ease of identifying/troubleshooting issues present in custom hosted control codebase.

Hope this blog post helped in understanding the instrumentation framework within USD.  Thanks for your time in reading this blog post. 🙂