Why debug in production?

Mikey

September 13, 2019

Why debug in production?

Why would I debug in production?

The optimist inside us all hopes that we will never need to debug in production as the released code is perfect. This is unfortunately not the case, even with 100% code coverage and strenuous manual testing there will be corner cases that are missed and found by customers.


When a corner case occurs in production, reproducing the issue locally is often a complex process that can take days or weeks. It may not even be possible at all!


Having a way to debug in production is an invaluable tool, as it eliminates the need to reproduce issues locally. Instead, you can find and fix the issue on the running system.

Is it safe to debug in production?

Debugging in production is completely safe if performed using one of the following debugging methods;

  1. Non-breaking / Non Intrusive debuggers - First introduced in 2014, non-blocking debuggers capture all the required debug data without pausing the execution of code.
    They provide more data than logging ever could without the need to restart or redeploy the application.
  2. Logging - The tried and true method of debugging through error logs and printing out variable values.
    Logging is familiar to every developer and heavily relied on in the software industry.


When debugging in production, it is important to avoid any blocking debuggers such as remote debuggers running in an IDE as they prevent stop users from interacting with your application.

What is the most common way of debugging in production?

By far the most common method of debugging is using logging. Hunting through log files to see exactly what occurred at the time of the error, then adding additional log statements to the application to find an issue where necessary.


There can be no doubt that this method works, however, this approach is not perfect. In order to debug through logging, you require access to log files which can be tricky in large production environments. Typically if you are required to add additional logging you must also restart or redeploy your application.

There is a better way to debug in production, using a non-breaking debugger in production gives you all the benefits of logging, without the drawbacks that can make logging difficult to configure and utilize.

How do I debug in production?

A perfect debugging tool for production environments should:

  1. Have all the stack and variable data required to debug
  2. Avoid having to restart your application to start debugging
  3. Not disrupt the users of your application as to debug an issue
  4. Not slow down the performance of the application to gather debug data


Using a non-breaking debugger such as nerd.vision satisfies all these points. You can set up and debug an issue with nerd.vision in 4 simple steps:

  1. Create a workspace for the application code
  2. Perform a one time install of the debugging agent
  3. Set a breakpoint on a line of code within the application
  4. View the debug data when the breakpoint fires and debug your issue

Mikey

Mikey

Technical Support Engineer and Developer advocate for nerd.vision and other software projects. Background in object-oriented software development and data analysis. Personal hobbies include simulation gaming and watch collecting.