Skip to content

Disable Spring Cloud Sleuth when running Integration Tests?

When using and running my integration tests locally I get this error message:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘stackdriverSender’ defined in class path resource [org/springframework/cloud/gcp/autoconfigure/trace/StackdriverTraceAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [zipkin2.reporter.Sender]: Factory method ‘stackdriverSender’ threw exception; nested exception is The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See for more information.

This is totally understandable since this environment variable is not present locally and I don’t want to use Sleuth/Stackdriver tracing when running the tests. I’ve looked in the reference documentation but I can only seem to find information on how to disable Sleuth for specific integration points such as RxJava, RestTemplate etc. But how can I disable Sleuth entirely?

I’ve tried setting spring.sleuth.enabled=false but this doesn’t seem to make any difference.



I actually found the answer by looking at the source for the StackdriverTraceAutoConfiguration class. The way to solve it if using GCP is to set This disables tracing for all integration points.