Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
In this series of labs, you take a demo microservices Java application built with the Spring framework and modify it to use an external database server. You adopt some of the best practices for tracing, configuration management, and integration with other services using integration patterns.
In a microservices architecture, you need distributed tracing to make complicated service calls more visible. For example, when service A calls B, and B calls C, which service has a problem? In Spring Cloud GCP, you can easily add distributed tracing by using Spring Cloud Sleuth. Spring Cloud Sleuth typically requires you to run and operate your own Zipkin backend.
In this lab, you implement distributed tracing by using Spring Cloud GCP, Spring Cloud Sleuth, and Cloud Trace. Spring Cloud GCP provides a starter that can interoperate with Spring Cloud Sleuth, but it forwards the trace request to Cloud Trace instead.
Cloud Trace is a distributed tracing system that collects latency data from your applications and displays it in the Google Cloud console. You can track how requests propagate through your application and receive detailed, near-real-time performance insights. Cloud Trace automatically analyzes all traces of your application to generate in-depth latency reports to surface performance degradations. It can also capture traces from all of your VMs, containers, or App Engine projects.
Language-specific SDKs for Cloud Trace can analyze projects running on VMs, even projects not managed by Google Cloud. The Trace SDK is available for Java, Node.js, Ruby, and Go. Cloud Trace API can be used to submit and retrieve trace data from any source. A Zipkin collector is also available, which enables Zipkin tracers to submit data to Cloud Trace. Projects running on App Engine are automatically captured.
In this lab, you learn how to perform the following tasks:
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is a panel populated with the temporary credentials that you must use for this lab.
Copy the username, and then click Open Google Console. The lab spins up resources, and then opens another tab that shows the Choose an account page.
On the Choose an account page, click Use Another Account. The Sign in page opens.
Paste the username that you copied from the Connection Details panel. Then copy and paste the password.
After a few moments, the Cloud console opens in this tab.
After you complete the initial sign-in steps, the project dashboard appears.
In this task, you clone the source repository files that are used throughout this lab.
To begin the lab, click the Activate Cloud Shell button at the top of the Google Cloud Console.
To activate the code editor, click the Open Editor button on the toolbar of the Cloud Shell window.
You can switch between Cloud Shell and the code editor by using Open Editor and Open Terminal icon as required.
Now you're ready to go!
In this task, you enable the Cloud Trace API.
In this task, you add the Spring Cloud GCP Trace starter to the pom.xml files for the guestbook service and the guestbook frontend applications.
Open Editor icon and then, open ~/guestbook-service/pom.xml.</dependencies> tag:~/guestbook-frontend/pom.xml.</dependencies> tag:In this task, you disable trace completely for the default profile and configure trace sampling for all requests in the cloud profile.
You get full trace capability simply by including the starters. However, only a small percentage of all requests have their traces sampled and stored by default.
For testing purposes, you disable trace in the application.properties files used for the local profile.
For the cloud profile for the guestbook backend, you enable trace sampling for all requests in the application.properties file used for the cloud profile.
cloud profile:For the cloud profile for the frontend application, you enable trace sampling for all of the requests in the application.properties file used for the cloud profile.
cloud profile:In this task, you create a service account with permissions to propagate trace data to Cloud Trace.
Open Terminal icon. To create a service account specific to the guestbook application, type the following commands in Cloud Shell:This command creates Service Account Credentials that are stored in the $HOME/service-account.json file.
service-account.json file as your own username/password. Do not share this information.
In this task you start both the frontend application and backend service application using the additional spring.cloud.gcp.credentials.location property. The property specifies the location of the Service Account Credential that you created.
guestbook-service directory:The application takes a minute or two to deploy and you should wait until you see that the GuestbookApplication is running:
Open a new Cloud Shell tab by clicking the Add icon to the right of the title of the current Cloud Shell tab.
Change to the guestbook-frontend directory:
In this task you examine the trace. Spring Cloud Sleuth has generated and propagated the trace. After a few seconds it propagates to Cloud Trace.
Open the Google Cloud console browser tab.
On the Google Cloud console title bar, in the Search field, type Trace , click Search.
On the trace explore page, click Back to Legacy to navigate to the trace window.
At the top of the window, set the time range to 1 hour.
Turn on Auto reload. New trace data may take up to 30 seconds to appear.
To view trace detail, click the blue dot.
In this lab you enabled the Cloud Trace API. You used Spring to add Cloud Trace to your application. You also configured customized trace settings in an application, before finally inspecting the trace output.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one