I have these two dependencies in my POM file:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-trace</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-logging</artifactId>
</dependency>
I'd like to disable these GCP features in certain profiles. I need to test my app locally but GCP keeps getting in the way.
Spring depends on auto-configuration when setting up the application. In many cases, it scans the classpath for certain dependencies, and if they are present, auto-configuration is performed. Most of the times the auto-configuration can be bypassed by providing a certain conditional.
While traversing the Spring cloud gcp modules I came across the StackdriverLoggingAutoConfiguration
class (source) and StackdriverTraceAutoConfiguration
(source).
StackdriverLoggingAutoConfiguration has the conditional ConditionalOnProperty(value="spring.cloud.gcp.logging.enabled", matchIfMissing=true)
, while StackdriverTraceAutoConfiguration has the conditional @ConditionalOnProperty(value="spring.cloud.gcp.trace.enabled", matchIfMissing=true)
I'm not entirely sure if the properties are related to the auto-configuration of the modules you use, but you migh be able to disable the logging by adding the following to your application-{localprofile}.properties:
spring.cloud.gcp.logging.enabled=false
spring.cloud.gcp.trace.enabled=false
Because the question is
How to disable Google Cloud Platform integration
I would suggest to just change our configuration with
spring:
cloud:
gcp:
core:
enabled: false
It should be enough to disable everything related to Spring Cloud GCP in our project
The accepted answer tells you how to disable a part of the GCP feature used in our project. If you have many of them (logging, PubSub, Storage, ...) it can be cumbersome to disable all of them. This is a shortcut to disable all of them at once ;-)
you can disable tracing,, logging and provide a fake id as follow:
spring.cloud.gcp.project-id=fake-project-id
spring.cloud.gcp.logging.enabled=false
spring.cloud.gcp.trace.enabled=false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With