openzipkin / zipkin-reporter-java

Shared library for reporting zipkin spans on transports such as http or kafka
Apache License 2.0
126 stars 70 forks source link

spring-beans 2.5.6 -> 3.0.0.RELEASE; fix @Bean AutoConfiguration mult… #212

Closed victory-wu closed 7 months ago

victory-wu commented 1 year ago

After Springbean version 3.0, FactoryBeans automatically configured through @ bean encountered a not found bean error

The reason is that no specific generic type was specified。

In order to reduce the impact, I only upgraded to the minimum version number that supports AbstractFactoryBean

The following is a code example。

erro:not fund AsyncReporter Sender 。。。


    @Bean
    public  OkHttpSenderFactoryBean sender() {
        OkHttpSenderFactoryBean okHttpSenderFactoryBean = new OkHttpSenderFactoryBean();
        okHttpSenderFactoryBean.setEndpoint("http://localhost:9412/api/v2/spans");
        return okHttpSenderFactoryBean;
    }

    @Bean
    public  AsyncReporterFactoryBean reporter(Sender sender) throws Exception {
        AsyncReporterFactoryBean asyncReporterFactoryBean = new AsyncReporterFactoryBean();
        asyncReporterFactoryBean.setSender(sender);
        asyncReporterFactoryBean.setCloseTimeout(500);
        return asyncReporterFactoryBean;
    }

    @Bean
    public ZipkinSpanHandlerFactoryBean spanHandler(AsyncReporter reporter) {
        ZipkinSpanHandlerFactoryBean factoryBean = new ZipkinSpanHandlerFactoryBean();
        factoryBean.setSpanReporter(reporter);
        return factoryBean;
    }
codefromthecrypt commented 11 months ago

hmm I can understand what you are asking about. On the other hand, we do have code that uses later versions of spring with this dependency. Also, this dependency is intentionally old to support 2.5. To update this will make those apps stop working. Can you have another look, perhaps at the brave-example to see if there is another way to accomplish your goal? https://github.com/openzipkin/brave-example/blob/7c3d4ce09ab81066ae909273792f19cee34229ef/webmvc4-boot/src/main/java/brave/example/TracingAutoConfiguration.java

codefromthecrypt commented 11 months ago

I haven't had time to create tests for this as there is some more urgent work I have to complete. If someone else can, it is appreciated.