Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncReporter Not Submitting Span Data to Zipkin Server with Servlet 2.5 #385

Closed
skyairmj opened this issue Apr 30, 2017 · 8 comments
Closed

Comments

@skyairmj
Copy link

We have a legacy system, which is based on Spring web 3.0.5 & Servlet 2.5. I'm trying to introduce brave 3.16.0 & zipkin-reporter 0.6.9 to trace the request / response.

When I set up BraveServletFilter with LoggingReporter in web.xml, I can see the correct output on the console:

==========Reporter Class: class com.github.kristofa.brave.LoggingReporter+===========
brave.LoggingSpanCollector {"traceId":"7a881bfb88affb67","id":"7a881bfb88affb67","name":"get","timestamp":1493524529589000,"duration":63087,"annotations":[{"timestamp":1493524529589000,"value":"sr","endpoint":{"serviceName":"ifpay-system-account","ipv4":"192.168.34.1"}},{"timestamp":1493524529652087,"value":"ss","endpoint":{"serviceName":"ifpay-system-account","ipv4":"192.168.34.1"}}],"binaryAnnotations":[{"key":"http.status_code","value":"200","endpoint":{"serviceName":"ifpay-system-account","ipv4":"192.168.34.1"}},{"key":"http.url","value":"/Account/rpc/testAcc","endpoint":{"serviceName":"ifpay-system-account","ipv4":"192.168.34.1"}}]}

But when I changed it to BraveServletFilter with AsyncReporter and OkHttpSender, I can't see the trace data on the zipkin server, although I can still see the logging on the console:

==========Sender Endpoint: http://localhost:9411/api/v1/spans+===========
==========Reporter Class: class zipkin.reporter.AsyncReporter$BoundedAsyncReporter+===========
brave.LoggingSpanCollector {"traceId":"14889b641ac3d014","id":"14889b641ac3d014","name":"get","timestamp":1493524682466000,"duration":212001,"annotations":[{"timestamp":1493524682466000,"value":"sr","endpoint":{"serviceName":"ifpay-system-account","ipv4":"192.168.34.1"}},{"timestamp":1493524682678001,"value":"ss","endpoint":{"serviceName":"ifpay-system-account","ipv4":"192.168.34.1"}}],"binaryAnnotations":[{"key":"http.status_code","value":"200","endpoint":{"serviceName":"ifpay-system-account","ipv4":"192.168.34.1"}},{"key":"http.url","value":"/Account/rpc/testAcc","endpoint":{"serviceName":"ifpay-system-account","ipv4":"192.168.34.1"}}]}

I also create a sample(https://github.com/mingjin/example-spring-mvc-initializer/blob/zipkin/src/main/java/eu/kielczewski/example/initializer/AppInitializer.java) about AsyncReporter and OkHttpSender with Servlet 3.x and WebApplicationInitializer, everything works fine.

So my questions are:

  1. Is it a bug in AsyncReporter? Or does not AsyncReporter support Servlet 2.5?
  2. If no, is there any particular configuration I miss?

Thanks,

@codefromthecrypt
Copy link
Member

codefromthecrypt commented Apr 30, 2017 via email

@skyairmj
Copy link
Author

Thank @adriancole for explaining why the reporter doesn't work.

Bellow are the Spring bean definitions(in Grails BeanBuilder DSL format) and filter definitions, however, there isn't any SpanCollecter settings. Would you please help disable the SpanCollecter?

beans = {
    sender(OkHttpSender, "http://localhost:9411/api/v1/spans") { bean ->
        bean.factoryMethod = "create"
    }
    reporterBuilder(AsyncReporter, sender) { bean ->
        bean.factoryMethod = 'builder'
    }

    reporter(reporterBuilder:"build")

    braveBuilder(Brave$Builder, "myservice")
    braveBuilderSetReporter(MethodInvokingFactoryBean){
        targetObject = braveBuilder
        targetMethod = "reporter"
        arguments = reporter
    }
    brave(braveBuilder:"build")
    braveServletFilterBuilder(BraveServletFilter$Builder, brave)
    braveServletFilter(braveServletFilterBuilder:"build")
}
    <filter>
        <filter-name>braveZipkinServletFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <init-param>
            <param-name>targetBeanName</param-name>
            <param-value>braveServletFilter</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>braveZipkinServletFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

@codefromthecrypt
Copy link
Member

codefromthecrypt commented Apr 30, 2017 via email

@skyairmj
Copy link
Author

@adriancole Thanks for your time.

Yes, it's very weird & confused, since the almost same configuration applied in another project(https://github.com/mingjin/example-spring-mvc-initializer/tree/zipkin) works. You can check the code & settings.

Bellow is the dependency snippet I'm using on the legacy project:

        compile 'io.zipkin.java:zipkin:1.16.2'

        compile('io.zipkin.brave:brave-core:3.16.0',
                'io.zipkin.reporter:zipkin-reporter:0.6.9',
                'io.zipkin.reporter:zipkin-sender-okhttp3:0.6.9'){
            excludes "zipkin"
        }
        compile 'io.zipkin.brave:brave-core-spring:3.16.0'
        compile 'io.zipkin.brave:brave-web-servlet-filter:3.16.0'

@codefromthecrypt
Copy link
Member

codefromthecrypt commented Apr 30, 2017 via email

@skyairmj
Copy link
Author

skyairmj commented May 3, 2017

After digging into the code, I found out it's due to the misconfiguration of Spring beans, of which the return object of MethodInvokingFactoryBean (with reporter bound) instead of the original 'braveBuilder' should be used to build the Brave instance.

The bean definition should be as bellow:

    braveBuilder(Brave$Builder, "myservice")
    braveBuilderWithReporter(MethodInvokingFactoryBean){
        targetObject = braveBuilder
        targetMethod = "reporter"
        arguments = reporter
    }
    brave(braveBuilderWithReporter:"build") // instead of 'braveBuilder'

Besides, I upgrade the Brave and zipkins to new versions as bellow:

        compile 'io.zipkin.java:zipkin:1.19.2'

        compile('io.zipkin.brave:brave-core:4.0.6',
                'io.zipkin.reporter:zipkin-reporter:0.6.12',
                'io.zipkin.reporter:zipkin-sender-urlconnection:0.6.12'){
            excludes "zipkin"
        }
        compile 'io.zipkin.brave:brave-core-spring:4.0.6'
        compile 'io.zipkin.brave:brave-web-servlet-filter:4.0.6'

Now Brave / AsyncReporter submits span data correctly to Zipkin server as expected.

Thank @adriancole , and hope this help other guys in the future.

@codefromthecrypt
Copy link
Member

codefromthecrypt commented May 3, 2017 via email

@codefromthecrypt
Copy link
Member

Brave 4.3 is being released now and include new support for Spring XML configuration, etc. Please give it a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants