The Snapshot Debugger takes a snapshot of your in-production Azure app when an exception occurs or at other points of interest. It lets you see exactly what went wrong, without impacting traffic of your production application.
This is a completely new feature of Application Insights and Visual Studio that we’re excited to announce today. It will help you, as a web developer on Azure, to dramatically reduce the mean time to resolution of issues found in production environments.
First, we’ll cover the public preview of Automatic Snapshots for .NET available today, and then we’ll cover the interactive Snappoints and Logpoints capabilities you can sign-up to try out under a private preview program.
Diagnosing issues in production is hard
No-one wants to encounter issues in their production services, and everyone want to run at cloud speed. Logs and Metrics are standard tools used by developers and DevOps engineers – and they help a lot – but there are plenty of bugs where logs and metrics don’t pinpoint the root cause.
Diagnosing issues in the cloud is especially time consuming for a few reasons:
- Issues are often caused by different configuration, data, and usage patterns
- You don’t have the same debugging tools readily available in the cloud that you have locally
- Your production site is serving live traffic, so you are limited in what you can do
We are in the unique position to solve this problem at Microsoft with our 20+ years of experience building Visual Studio. We built the Snapshot Debugger to help you solve these problems too.
Automatic snapshots triggered by telemetry
The Snapshot Debugger is a new tool that is built for production. It will help you find any problem, no matter how hard, especially when logs leave you hanging.
With our public preview of the Snapshot Debugger enabled, Application Insights will automatically capture snapshots on exceptions observed in your environment.
Simply configure Application Insights to collect exceptions, include the Microsoft.ApplicationInsights.SnapshotCollector NuGet package in your app, and you will see Open Debug Snapshot links appear on exceptions in the Application Insights portal.
You can open debug snapshots and get a light-weight viewing experience in the portal, powered by Visual Studio’s debug engine running in the cloud. Here you can explore the call stack and local variables in each frame:
Full-fidelity debugging in Visual Studio
From the variables shown you might be able to identify the root cause of an issue immediately, but you may need to dig deeper into the snapshot to understand the issue. To get the full power of the Snapshot Debugger, you can click “Download Snapshot” to download a .diagsession file containing the snapshot and symbol files collected from the production environment that allow the debugger to map back to source code.
The snapshot file can be opened by Visual Studio Enterprise 2017 with our Snapshot Debugger extension installed, allowing you to see the full state of the process at that moment in time:
In Visual Studio you can use the full power of the debugger to inspect the state of the program the moment the exception was thrown. All the capabilities of dump debugging work here.
Interactive snapshot debugging with Snappoints and Logpoints
So far we’ve talked about what’s available for anyone to try out today. We are also inviting you to sign-up for a private preview program for the Snappoints and Logpoints features of the Snapshot Debugger we showed at Build 2017. These features will be available as a public preview this summer.
The automatic snapshots on exceptions are a good place to start, but what if you have further hypotheses to test your production environment? You can attach Visual Studio to applications running in Azure in live snapshot debugging mode. In this mode, clicking on the breakpoints “gutter” will set Snappoints that will trigger Snapshots to be collected when that line of code is executed in production.
Snapshots appear in the event log to the right, and you can double-click to debug the Snapshot using Visual Studio. We use correlation to make sure we collect multiple Snapshots from the same request if possible, allowing you to get insight into how state changed over time.
Sometimes you may be interested in tracking down an issue that only impacts a particular user, or only occurs under certain conditions. You can click the Snappoints configuration button to set conditions, making it easy for you type in an expression that will trigger snapshot collection.
For some bugs, you might not need a full Snapshot, but rather to view the values of variables as they change over time. You can set Logpoints by using the configuration page and checking “Actions” and providing a message.
Logs are shown in the output window and use standard logging APIs so that they can be picked up by standard monitoring and logging solutions such as Application Insights.
A debugger for the production cloud
Taking a process snapshot is fast -- it takes about 10ms – and creates a shadow copy of the running process by marking pages as copy-on-write. This means that memory can be analyzed offline while the main process continues running and serving traffic to users. Snapshots also have low memory overhead: memory is only copied when the main process writes to memory.
With this Snapshot capability we have built a full-fledged debugging experience that allows you to use the tools you know and love, get the data you need to reproduce problems and root cause issues, without impacting user traffic. You can check out our //BUILD/ video to see the Snapshot Debugger in action.
Try out the preview today
This is just the beginning of our journey with the Snapshot Debugger, and we can’t wait to make all these capabilities – and more – available to you to help you debug at cloud speed in Azure.
Try out the public preview of Automatic Snapshots with Application Insights and Visual Studio today, and sign-up for our Snappoints and Logpoints private preview to be one of the first to try out these capabilities.