Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Google Cloud Platform integration?

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.

like image 692
Luke101 Avatar asked Apr 25 '19 16:04

Luke101


3 Answers

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
like image 147
Michiel Avatar answered Oct 08 '22 15:10

Michiel


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 ;-)

like image 36
bryce Avatar answered Oct 08 '22 15:10

bryce


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
like image 1
Elie Nehmé Avatar answered Oct 08 '22 13:10

Elie Nehmé