loggingzipkinspring-cloud-sleuthtraceability

How to track the span through different dependencies with Sleuth?


I'm learning how to track my distributed processes through all the microservices. I've been playing with Sleuth, Zipkin and different microservices, and it works fantastic! But when I try to do the same in a project interacting between the different dependencies I can not create the same behavior.

This image show how currently is working different microservices. enter image description here

This is the diagram of microservices: enter image description here

And this image show how works an application with dependencies. enter image description here

This is the diagram of application with dependencies: enter image description here

I wonder, is it possible to create the same behavior using dependencies as with microservices?


Solution

  • Taking the input of @MarcinGrzejszczak as reference, I resolved using a custom span:

    Span remoteDependency = tracer.nextSpan()
                                  .name("dependency_name") 
                                  .start();
    

    Where tracer is an autowired object from Trace:

    @Autowired
    private Tracer tracer;
    

    Both classes are in brave package

    import brave.Span;
    import brave.Tracer;
    

    Result:

    Sample

    If you want to take a look at the implementation in more detail, here is the sample: https://github.com/juanca87/sample-traceability-microservices