[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] camel pull request #2448: CAMEL-12656: Fixed root span id for multiple route...

GitHub user st2654 opened a pull request:


    CAMEL-12656: Fixed root span id for multiple routes.

    I have added screenshots in Jira already.
    Camel-Zipkin does not report traces with root span id when there are multiple routes. 
    For example: 
    Root SpanId(TraceId) should be for service-name = direct:foo and the trace in UI should show all the 4 routes in one sequence. But it breaks. Check the attached screenshot: Traces Breaking.png
    I looked into the code and figured out why its happening. Here is the code which is breaking the functionality.
    Class Name: ZipkinTracer.ZipkinRoutePolicy
    Inside onExchangeBegin() method 
    // add on completion after the route is done, but before the consumer writes the response
    // this allows us to track the zipkin event before returning the response which is the right time
    exchange.addOnCompletion(new SynchronizationAdapter() {
        public void onAfterRoute(Route route, Exchange exchange) {
            String serviceName = getServiceName(exchange, route.getEndpoint(), true, false);
            Brave brave = getBrave(serviceName);
            if (brave != null) {
                serverResponse(brave, serviceName, exchange);
        public String toString() {
            return "ZipkinTracerOnCompletion[" + routeId + "]";
    Using onAfterRoute() :  if the exchange is being routed through multiple routes, there will be callbacks for each route.
    I have fix for it: 
    If I use onExchangeDone() instead of above code. The traces are reported properly.  Check screenshots.
    Note This process must be repeated if the service makes multiple downstream calls. That is each subsequent span will have the same trace id and parent id, but a new and different span id.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/st2654/camel CAMEL-12656

Alternatively you can review and apply these changes as the patch at:


To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2448
commit ca7fdaecc6645506a81c24409602ba3819b169b5
Author: Sourabh Taletiya <st2654@...>
Date:   2018-08-01T03:49:24Z

    CAMEL-12656: Fixed root span id for multiple routes.