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.
Successfully complete this lab by achieving the following learning objectives:
- Deploy the Demo Application
Inside the GCP console, click the Activate Cloud Shell icon.
Clone the Git repo from GitHub.
appengine-buggydirectory inside the repo, deploy the application to App Engine.
You will be asked to choose a region for deployment, then confirm the details to create the application. When the command completes you should be able to see the URL of your deployed app.
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).
sample_textis sometimes not set because of the
if random_valuecondition. 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
ifcondition on line 21 of
sample_textis 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!
Redeploy the application to App Engine, and test that your change has solved the problem by reloading the app several times.
You can now mark the Error as resolved in Error Reporting.