I have a Spring Boot 2.7.x application which is running GCP Kubernetes. Several GCP products are working properly including logging, datastore etc..
I wanted use Google Cloud Trace and followed this and used GCP sample project here Please note that the most recent version of this sample project uses Spring Boot 3.x.x. The provided link here is an old version which is using Spring Boot 2.7.x
What I changed
Application.yaml
spring:
sleuth:
sampler:
probability: 1.0
web:
enabled: true
enabled: true
reactor:
enabled: true
async:
enabled: true
client:
template:
enabled: true
zipkin: # All zipkin features disabled for integration tests
enabled: true
logging.level:
org.springframework.cloud: DEBUG
com.google.cloud: DEBUG
build.gradle file
implementation platform("com.google.cloud:spring-cloud-gcp-dependencies:3.4.3")
implementation "com.google.cloud:spring-cloud-gcp-logging"
implementation "com.google.cloud:spring-cloud-gcp-starter-pubsub"
implementation "com.google.cloud:spring-cloud-gcp-starter-trace"
To test it, I triggered some endpoints inside my app. In the logs there are below 2 debug logs from spring (with different ids)
Handled send of span [NoopSpan(656731a1275935f02630b37e25545eca/2630b37e25545eca)]
Created a server receive span [NoopSpan(656731a1e8bdc89e38f060196094f310/38f060196094f310)]
Even if I do not trigger any endpoint, this lines are printed in logs in regular intervals.
However no trace data arrives to Cloud Trace page. I also checked Cloud Trace API monitoring charts, again nothing arrives there.
Then I included this additional header in my endpoint request 'X-Cloud-Trace-Context: 205445aa7843bc8bf206b12000100003/1;o=1'
and it worked
And this time there were different logs; RealSpan(205445aa7843bc8bf206b12000100002/4a30d753bbadebd2)]
before my execution and Handled send of span [RealSpan(205445aa7843bc8bf206b12000100002/4a30d753bbadebd2)]
after the execution.
When I run it locally, it just works without X-Cloud-Trace-Context header. I see 'RealSpan(....' logs locally.
So, I think tracing is there but not activated in GCP. According to their documentation, spring.sleuth.enabled should be automatically true thanks to "com.google.cloud:spring-cloud-gcp-starter-trace" I even set it to true manually but still it only works with X-Cloud-Trace-Context header. Interestingly it behaves differently on local and GCP
What should I do to make it active for all endpoints without requiring additional header?