1

In my code I have scheduled a runnable task using the schedule method of task schedular. I went through this link - https://docs.spring.io/spring-cloud-sleuth/docs/current-SNAPSHOT/reference/html/integrations.html#sleuth-runnablecallable-integration. I implemented this way. The current state is - for any schedule a trace is created, and the same trace id is being used for all the runs invoked by this schedule, though spans are new. But I want that each run should have it's own unique trace id. There is a method of tracer which creates a new trace, but is there any way to do this in sleuth by which I can avoid manual creation of a new trace? I am using the 2.0.x version.

Shubhangi
  • 11
  • 3

1 Answers1

0
  1. I created a new trace using newtrace method of tracer which returns a span.
  2. Started this span.
  3. Then added this span in the currentscope using withspaninscope method.
  4. Started scoped span for the runnable task and finished both of these spans.

It worked.

ouflak
  • 2,458
  • 10
  • 44
  • 49
Shubhangi
  • 11
  • 3