Setting Up Stackdriver Debugger on App Engine (Python)

Stackdriver Debugger is supported in the following App Engine environments:

Environment Support
Standard Enabled by default
Flexible: python version 2 Manual setup required
Flexible: python version 3 Not supported
Flexible: python27 Not supported

Configuration and deployment

Standard

No configuration required.

Deployment

  1. Install version 1.9.20 or later of the Google App Engine SDK on your local workstation.

  2. Commit and push your source code to your Git repository:

    git commit -m 'Commit message.'
    git push YOUR_REPO
    
  3. Deploy your application using the appcfg command:

    appcfg.py update APP_YAML_LOCATION
    

    For example:

    appcfg.py update myapp/
    

    The appcfg command generates a file named source-context.json in the app's root directory and uploads it with your application. This file contains information about the version of the source code used to build the application. When you open Stackdriver Debugger in the Google Cloud Platform Console, it uses the information in this file to display the correct version of the source.

Flexible: python

Note that Debugger doesn't support python_version: 3. Only version 2 is supported.

Configuration

  1. Add google-python-cloud-debugger to requirements.txt
  2. Add the following lines to your main function. They should be called as soon as possible in the code:

    try:
      import googleclouddebugger
      googleclouddebugger.AttachDebugger()
    except ImportError:
      pass
    

Deployment

Make sure your app.yaml file contains the following lines:

runtime: python
env: flex

Then:

  1. Commit and push your source code to your Git repository:

    git commit -m 'Commit message.'
    git push YOUR_REPO
    
  2. Deploy your application:

    gcloud app deploy
    

    The gcloud app deploy command generates a file named source-context.json in the app's root directory and uploads it with your application. This file contains information about the version of the source code used to build the application. When you open Stackdriver Debugger in the Google Cloud Platform Console, it uses the information in this file to display the correct version of the source.

Using the debugger

After deployment, you can use Stackdriver Debugger to capture and inspect the call stack and local variables in your application.

Send feedback about...

Stackdriver Debugger Documentation