Real-Time Troubleshooting with Google Cloud Error Reporting

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

You have been tasked with deploying your team’s application to App Engine, as a proof-of-concept demo for Platform-as-a-Service technologies that you will present to the rest of your organisation. The app will work just great — most of the time. For some reason, it also seems to return an internal server error, although you can’t see any bugs in your code when you run the app locally. In this lab, we will use GCP Error Reporting to see live errors and stack traces from our deployed application, to identify where the error is occurring.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Deploy the Demo Application
  1. Under "APIs & Services," "Library," search for "Cloud Build API." Click "ENABLE" to enable the Cloud Build API.

  2. Inside the GCP console, click the Activate Cloud Shell icon.

  3. Clone the Git repo from GitHub.

  4. From the appengine-buggy directory inside the repo, deploy the application to App Engine.

  5. You will be asked to choose a region for deployment (select us-east1), then confirm the details to create the application. When the command completes you should be able to see the URL of your deployed app.

  6. Visit the application in your browser. Did it work? Keep reloading the page until it breaks.

Use Cloud Error Reporting

View your application’s errors in the GCP console. You can find application errors in the App Engine dashboard, or in the Error Reporting section (under Operations in the GCP menu).

The variable sample_text is sometimes not set because of the if random_value condition. You can see the stack trace of this error, along with all of its occurrences, as a single Error in Error Reporting.

Fix the Application and Redeploy
  1. Remove the if condition on line 21 of so that sample_text is always set. Make sure you correct the indentation on the following line. You should probably change the text as well, so that it no longer claims to fail some of the time!

  2. Redeploy the application to App Engine, and test that your change has solved the problem by reloading the app several times.

  3. You can now mark the Error as resolved in Error Reporting.

Additional Resources

Note:  If the deploy fails, wait a moment, then retry the command. Make sure you use us-east1.

Log in to Google Cloud Platform by opening in a private browser window. Then, sign in using the credentials provided on the lab page.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?