spring-boot-data-source-decorator
spring-boot-data-source-decorator copied to clipboard
Add mechanism to disable decorating in runtime
For some projects there is no need in consistent logging of queries, but when some strange behavior was noticed. In this case it would be helpful to be able to disable decorating through spring cloud config.
see https://github.com/p6spy/p6spy/issues/460
I might, for instance, like to use P6Spy or datasource-proxy in a test configuration but not in prod; I don't see anything in the README to address this kind of approach.
@geoffreywiseman one option is disable decorating at non test environments (application.properties/yml in main sources) - decorator.datasource.enabled=false, it's mentioned in the very end of README. And then override this option only for tests using either separate test config file or @SpringBootTest(properties = "decorator.datasource.enabled=true"), there are also different options supported by Spring Boot.
In this case p6spy/datasource-proxy and decorator code will be on the classpath, but decorating will be disabled. If you want completely exclude it from the classpath you can configure your build tool to make starter a test dependency.