Skip to content
Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src Fix Trace sample not to generate 'async' traces (#2011) Nov 5, 2019
README.adoc Enforce one-sentence-per-line rule in adoc (#1345) Jan 3, 2019
pom.xml Bump versions post 1.2 release to 1.3 (#2058) Nov 26, 2019

README.adoc

Spring Cloud GCP Trace Starter Example

This sample application demonstrates using the Spring Cloud GCP Trace Starter in your code.

You can read about the Spring Boot Starter for Stackdriver Trace in more detail at the Spring Cloud GCP Reference Document Stackdriver Trace section.

Similar content is also available in the Distributed tracing with Spring Cloud Sleuth codelab.

Setup & Configuration

  1. Create a Google Cloud Platform Project

  2. Create a service account with Trace Append permission. Furnish a new JSON key and then set the credentials using the GOOGLE_APPLICATION_CREDENTIALS environment variable or using GCP Starter Core properties.

    Alternatively, if you have the Google Cloud SDK installed and initialized and are logged in with application default credentials, you can skip this step since Spring Cloud GCP will auto-discover those settings for you.

  3. Enable the Stackdriver Trace API

Run the Example

Run the example from Maven:

$ mvn spring-boot:run

Browse to http://localhost:8080. This will trigger the ExampleController.work() method, which in turn will call other services, and also a remote RESTful call to ExampleController.meet() method.

To see the traces, navigate to Stackdriver Trace console’s Trace List view. You should see the trace information in detail. Additionally, if you logged in with the Google Cloud SDK or have the GOOGLE_CLOUD_PROJECT environment variable set to your GCP project ID, you can also click the View link in front of the DetailsLog to view the log entries related to that trace ID.

Note that the trace transmission delay default value is 10 seconds, so it can take a little while for the traces to show up in the Trace List page. You can shorten this delay using the spring.cloud.gcp.trace.scheduled-delay-seconds property.

Deploy to App Engine Flexible Environment

If you have Cloud SDK installed, Maven App Engine Plug-in can be used to deploy the application to App Engine Flexible environment:

$ mvn appengine:deploy
You can’t perform that action at this time.