Search code examples
springspring-bootzipkinspring-cloud-sleuthopentracing

Span Customization with Google Cloud Sleuth 2


Is there a way to customize the Span inject and extractor for spring cloud sleuth 2? In the documentation of the version 1.2 i found a way that is not available on the new version(2). I think is because now its use Zipkin brave to take care of Span, right? https://cloud.spring.io/spring-cloud-sleuth/1.2.x/multi/multi__customizations.html#_example

I tried to back to use the stable version(1.3.3) of spring cloud sleuth, but when i use the bom for the project its make conflict in the spring boot version that i am using(2.0). Its compactible with the spring boot version 2?

I am using the spring cloud sleuth to make trace of services on my company, but i have a version of tracing on others services that is not compactible with the opentracing headers, so i want to change the headers of http messages to make the new services compactibles with the current tracing headers that i have in the others components.

Thanks


Solution

  • I tried to back to use the stable version(1.3.3) of spring cloud sleuth, but when i use the bom for the project its make conflict in the spring boot version that i am using(2.0). Its compactible with the spring boot version 2?

    You can't use the Sleuth 1.3 with Boot 2.0.

    I am using the spring cloud sleuth to make trace of services on my company, but i have a version of tracing on others services that is not compactible with the opentracing headers, so i want to change the headers of http messages to make the new services compactibles with the current tracing headers that i have in the others components.

    Yeah, that's the Brave change. For http you can define your own parses. https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.java#L57-L68 .

    @Autowired HttpClientParser clientParser; @Autowired HttpServerParser serverParser; @Autowired @ClientSampler HttpSampler clientSampler; @Autowired(required = false) @ServerSampler HttpSampler serverSampler;

    These are the samplers that you can register.

    For messaging you'd have to create your own version of the global channel interceptor - like the one we define here - https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/TraceSpringIntegrationAutoConfiguration.java#L49-L53 .

    If that's not acceptable for you, go ahead and file an issue in Sleuth so we can discuss it there.