Spring Opentracing Jaeger header forwarding with Istio - spring

I'm running Spring with the opentracing-spring-jaeger-web-starter in Istio with jaeger, even when I enable b3-propagation and w3c-propagation, jaeger is breaking the spans.
Is there a way to validate what the sidecar receives? I tried using WebClient and RestTemplate, same result with both. I don't want to forward the header manually in the controller.

Related

fix different traceId with istio sidecar proxy and spring boot sleuth

Spring boot apps with Sleuth are deployed in pods with istio sidecar injected alongside.
istio virtual service ingresses traffic into the mesh and proxies the request to pods correctly.
Both logs are seen in kibana - one for istio-proxy (sidecar) and another for the spring app using logback + sleuth.
However I would like to see same traceId (x-request-id) header for both requests. Is this a good practice or is rather what is the right way to join/tie these request logs ?
I did one test and found out that istio-proxy is sending 'x-request-id' which corresponds to the value of traceId. However spring creates a new traceId and wondering if there is a way to make them same ?

Spring Boot actuator for backend application

I use Spring-boot 2.2.x for my backend application - spring-kafka + streams. My service will be deployed in Kubernetes as Docker image. I would like to add spring-boot-starter-acutator, but as I checked, from Spring-boot 2.x actuator requires spring-boog-starter-web. And there is a question what is a proper way to use actuator over http and use http server only actuator - management scope/context?
I know that I can use jmx instead of http but I would prefer http.

Sending Zipkin Spans for #FeignClient

I'm running a Spring Boot app using:
Spring Boot 2.3.8
Spring Cloud Hoxton.SR10
I've declared the spring-cloud-starter-zipkin and spring-cloud-starter-openfeign dependencies, and have configured my app to point to a Zipkin server. Its a pretty vanilla setup and configuration (I also declare the spring-cloud-starter-netflix-ribbon and spring-cloud-starter-kubernetes-all dependencies o allow Spring Feign to use k8s service discovery).
My app declares a #SpringFeign annotated interface with a method to call to a remote service S.
So generally zipkin is getting spans from my app (for e.g. incoming REST calls) and B3 headers are being propagated via HTTP to the service S being called through feign.
But zipkin does not report a span from my app representing the Feign call to S.
Is that something that should "just happen", or am I missing a piece of the puzzle?
I can e.g. add #NewSpan to the feign interface method, but that doesn't give me HTTP details for the request/response as span tags. And I rather not do that if this is supposed to work out of the box.
This should be done out of the box: https://docs.spring.io/spring-cloud-sleuth/docs/2.2.7.RELEASE/reference/html/#feign
You can take a look at the feign sample (you need to go back in the history, currently it is for 3.x): https://github.com/spring-cloud/spring-cloud-sleuth/tree/master/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-feign
In order to see if propagation works, look into the outgoing request, it should contain the tracing-related headers.

Rename X-B3-TraceId headers in spring cloud sleuth

I have few services written in Node that are using "X-Request-Id" as the header to identify requests. I am now writing services in Java using spring-boot where I can use spring-cloud-sleuth to track traceId and spanId.
However, I would like to continue using the "X-Request-Id" as the request identifier across all of my services. Is there any way to rename the "X-B3-TraceId" header in spring-sleuth so that it sends the same header in HTTP requests and also uses the said header from incoming requests to set the traceId?
You can propagate extra fields, see the Propagation section of the Spring Cloud Sleuth docs.
spring:
sleuth:
propagation-keys: x-correlation-id

how to exclude some calls with the Feign from tracing with the cloud sleuth

there's a microservice with spring-boot 1.5 which uses the Feign to communicate with others services, also there's spring-cloud-starter-zipkin which wrapped all calls through the Feign and sends tracing to zipkin server.
The thing is i don't wanna wrap all calls and trace them, there're only several most important to do that.
How can i exclude some calls(methods) with Feign from tracing or exlude some whole Feign client(interface)?
In Sleuth 1.3.x you can create a custom SpanReporter that, before sending a span to Zipkin, would analyze the URL and would not report that span. In Sleuth 2.0.x you can create a custom HttpSampler for the client side (with name sleuthClientSampler)

Resources