You can use Stackdriver Debugger with any Go application running on a Google Compute Engine instance. We recommend that you enable it on all running instances of your application.
Stackdriver Debugger works with Compute Engine instances running:
- A 64-bit Debian Linux image
For instructions on creating a Compute Engine instance, refer to Creating and Starting an Instance in the Google Compute Engine documentation.
Generate the source context file
The source context file contains information about the version of the source code used to build your application. The Debug page in the Cloud Platform Console uses this information to display the correct version of the source.
To generate the source context file, commit any outstanding changes and sync with your remote repository, then run the following in the root directory of your local Git repository.
gcloud beta debug source gen-repo-info-file [--output-directory <dir>]
Then, deploy (or redeploy) your application to your Compute Engine instance,
Download the agent
The Stackdriver Debugger agent is a light-weight binary that you enable for your application at startup. The agent starts with your application and communicates with the Stackdriver Debugger backend while the application is running.
Once you've built and deployed your Compute Engine application, download the pre-built agent executable:
wget -O go-cloud-debug https://storage.googleapis.com/cloud-debugger/compute-go/go-cloud-debug chmod 0755 go-cloud-debug
Then, start the agent and your program with:
./go-cloud-debug -sourcecontext=PATH_TO_FILE -appmodule=APP_NAME -appversion=APP_VERSION -- PROGRAM_NAME arg1 arg2
PROGRAM_NAMEspecifies the relative path to your application binary.
-sourcecontextspecifies the path to the JSON-formatted file containing your source context configuration. See Generate the source context file for information on generating this file.
-appmoduleis the name of your application or service. This, along with the version, is used to identify your application in the Cloud Platform Console.
-appversionis the app version (e.g. the build ID). The Cloud Platform Console displays the running version as
module - version. For example,
main - 1.0.
arg2are placeholders for any additional parameters that your application requires.
Using Stackdriver Debugger
After you have set up Stackdriver Debugger for use in your environment and you have started your application, you can open the Debug page in the Cloud Platform Console. See Using Stackdriver Debugger for more information.