spring-cloud / spring-cloud-sleuth

Distributed tracing for spring cloud
https://spring.io/projects/spring-cloud-sleuth
Apache License 2.0
1.77k stars 782 forks source link

DataSource Proxy + Spring Could Sleuth not working #2337

Closed adityazagade closed 8 months ago

adityazagade commented 8 months ago

Describe the bug SpringBoot version: 2.7.3 SpringCloud version: 2021.0.9 spring-cloud-starter-sleuth version: 3.1.10 Datasource Proxy version: 1.8.1

I have added these dependencies as mentioned in the documentation. However there is no logging. On application start-up, I see following errors:

[restartedMain] INFO org.springframework.cloud.context.scope.GenericScope - BeanFactory id=8f920f04-2bb9-3e6a-8e99-4005c6d97d36
[restartedMain] INFO org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration' of type [org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[restartedMain] INFO org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[restartedMain] INFO org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'loadBalancerClientsDefaultsMappingsProvider' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration$$Lambda$517/0x00000008013208a8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[restartedMain] INFO org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'defaultsBindHandlerAdvisor' of type [org.springframework.cloud.commons.config.DefaultsBindHandlerAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[restartedMain] INFO org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'spring.sleuth.jdbc-org.springframework.cloud.sleuth.autoconfig.instrument.jdbc.TraceJdbcProperties' of type [org.springframework.cloud.sleuth.autoconfig.instrument.jdbc.TraceJdbcProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

Isolated the test case here: https://github.com/adityazagade/sleuth-bug

adityazagade commented 8 months ago

If it is out of oss support, can you pls suggest a work-around?

adityazagade commented 8 months ago

If I remove sleuth from my dependencies, and instead add the following, I see the trace logs

    <dependency>
        <groupId>com.github.gavlyukovskiy</groupId>
        <artifactId>datasource-proxy-spring-boot-starter</artifactId>
        <version>1.8.1</version>
    </dependency>
adityazagade commented 8 months ago

I think there is some problem with 'TraceDataSourceDecoratorBeanPostProcessor' as I follow what's mentioned here:

https://stackoverflow.com/questions/1201726/tracking-down-cause-of-springs-not-eligible-for-auto-proxying

adityazagade commented 8 months ago

After spending enough time, I realised that this is not a bug. Presence of such warning does not mean that it's an issue. I was able to get logs by adding right set of properties in application.yml

spring.sleuth.jdbc.enabled=true spring.sleuth.jdbc.datasource-proxy.enabled=true spring.sleuth.jdbc.datasource-proxy.slow-query.enable-logging=true spring.sleuth.jdbc.datasource-proxy.slow-query.threshold=10000 spring.sleuth.jdbc.datasource-proxy.slow-query.log-level=DEBUG spring.sleuth.jdbc.datasource-proxy.query.enable-logging=true spring.sleuth.jdbc.datasource-proxy.query.log-level=DEBUG logging.level.net.ttddyy.dsproxy.listener=DEBUG spring.sleuth.jdbc.datasource-proxy.multiline=true