GKE Stack Driver Trace Reporting By Cluster By Environment By Service By Service Version

3/24/2019

We have multiple spring boot and python apps running on top of GKE and for spring boot applications am using spring-cloud-gcp-starter-trace to log traces to stack driver so that I can debug those traces via the stack driver UI.

Am not able to figure out how to add labels like service_name, service_version and cluster_name so that I can filter out only those traces for reporting purposes because right now we have istio configured on one cluster and even with one percent sampling rate it's generating tons of telemetry data and with UN-availability of filters or am missing some configuration, the trace UI has almost become useless for me

I had a look at the documentation for spring-cloud-gcp-starter-trace, they don't have any properties through which I can set these fields, Am setting app name and app version via the metadata tags of the kubernetes deployment template but they aren't getting picked up.

Can some one please let me know how can I achieve this.

-- Rajiv
google-cloud-platform
google-cloud-stackdriver
google-kubernetes-engine
spring-cloud

2 Answers

3/25/2019

If you're using OpenCensus, you can use annotations to pass metadata into the Trace backend: https://cloud.google.com/trace/docs/setup/java#custom_spans.

I don't see anything in spring-cloud-gcp-starter-trace documentation (what little I could find) regarding annotations however.

-- Yuri Grinshteyn
Source: StackOverflow

3/28/2019

You can add custom tags using the brave.SpanCustomizer. Just autowire it in as the bean already exists in the application context. You can then add tags like this:

@Autowired
SpanCustomizer spanCustomizer;

...

spanCustomizer.tag("my-tag", "my tag value");

These will turn into labels on you traces in Stackdriver Trace, on which you can search.

-- Mike E.
Source: StackOverflow