Search code examples
spring-boottracespring-cloud-sleuthzipkin

How to retrieve spanid using java in Sleuth version 2.0.4


I need to know the SpandId in java code but I don't know how to get it. I had been searching and I found that many people refer to Tracer class, but it is not available at sleuth 2.0.4.

Does anybody know how to get the SpandId using sleuth 2.0.4?

Thanks!


Solution

  • Just inject the brave.Tracer bean and then you can call tracer.currentSpan().context().spanId() or tracer.currentSpan().context().spanIdString()