I am a Developer Advocate. As part of my job I show off some of Google’s products at conferences, and I teach folks about products that may help them make cool things. The product I am most excited about at the moment is Stackdriver Debugger. Every time I get to demonstrate Debugger at a conference people are initially incredulous. Once they see that it actually works and I’m not just making stuff up they are either excited or curious about how it works.
What it does
Stackdriver Debugger allows you to take a snapshot of an application running in production at a specific point in the code without needing to deploy an instrumented version of that code. The snapshot captures local variable state and a stack trace so that you can see the path a given request took through your code and hopefully address the underlying issue.
Snapshots can be set up conditionally so that Debugger will only take a snapshot if an error code is set, for example. You can also include additional expressions you want to be included in the snapshot. This is useful to see values from deeply nested data structures or to see the value of a variable that is outside the local scope.
I usually use Stackdriver Debugger from the web UI, and I upload my code so that I can set the snapshot point visually. You can also use Debugger without uploading your code or point it at a repository in the cloud on GitHub, BitBucket, or a Google Cloud Source Repository.
It makes sense to me that this is possible in an interpretted language like Python but Debugger also supports Java, Go, and Node.js, which still seems like magic. I had a chance to talk to the folks working on Debugger support for some of the other languages Google Cloud supports and they are doing some amazing things to enable production debugging.
Languages and Basic Set Up
Currently, Stackdriver Debugger supports Go, Python, Java, and Node.js. There’s an alpha library for Ruby that is under active development. I hope to try it out on a Rails App running in a few different environments in the next month or two.
To set up your app to use Debugger you need to install the Stackdriver Debugger agent. Each environment is a bit different but should make sense for the language. For Python you install it with pip, with Node.js you use npm, Ruby installs as a gem, etc. Once you have the agent installed, you can use the web UI to take and view snapshots. You can also set up snapshots from the command line like this
gcloud debug snapshots create FILE_NAME:LINE_NUMBER. More information about setting up snapshots is available in the Debugger documentation.
One of my early mentors talked about wanting to build “the water dispenser on the refrigerator.” His goal was to create things that people did not know they wanted or didn’t think were possible but delighted folks when they first used it. For me, Debugger is one of those products. Live production debugging even of compiled code with minimal added latency seems like it should be impossible but yet, it works.