spring-cloud-sleuth
spring-cloud-sleuth copied to clipboard
Propagating traceId to a spring-cloud-task application
Hi
I have a number of spring-boot services running in kubernetes. The same traceId for a request is generally propagated between services. However when a "task-launcher" service launches a spring-cloud-task via a spring-cloud-stream TaskLaunchRequest in a sink, the pod that is spawned uses a different traceId. Would someone be able to advise what the best approach is to ensure that the traceId used by the application running in the pod uses the same traceId as the task-launcher application and that the traces are therefore stacked appropriately?
Thanks
Can you create a sample that replicates this problem? cc @cppwfs
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Here is the issue that @zargarf opened on Spring Cloud Task https://github.com/spring-cloud/spring-cloud-task/issues/859
I am creating a TaskLaunchRequest which is consumed by the TaskLaucherSink in spring-cloud-task-stream.
This instantiates a task pod and runs an implementation of the CommandLineRunner(called QueryRunner).
However the traceId in the service that contains the TaskLauncherSink is different to the traceId in the task pod when I look at the logs.
If I pass the traceId as a property in the TaskLauchRequest to the task pod then I can force the trace id the same by injecting a tracer into the QueryRunner and using:
this.tracer.startScopedSpanWithParent("queryRunner",TraceContext.newBuilder().spanId(passedintraceid).spanId(passedinspanid).build());
However I was under the impression that the propagation of the traceid should happen out of the box without having to do this. Is this the case?
I am using spring-boot 2.7.1, spring-cloud-sleuth: 3.1.3, spring-cloud-task : 2.4.4
This is not supported out of the box by Spring Cloud Sleuth. Since Sleuth is feature complete we are not planning to add this functionality