title: How do I access the current span and trace ids in a Spring Reactor context?
body: <p>In my Spring Boot WebFlux application, I am using Reactor.  I have set spring.sleuth.reactor.instrumentation-type=manual and am using @ContinueSpan on a service method.  I see from the code that the span is created, started and ended appropriately in a reactive way.</p>
  <p>Later, in the Flux I need to extract the trace information.</p>
  <p>The code I am using injects Tracer and I use Tracer.currentSpan().context() to try to get to the trace context.  I can successfully get the currentSpan() until I hit a call to an R2DBC repository method, after which the currentSpan is null. I can make the span &quot;current&quot; by annotating the repository method, but I do not want to do that unless it's necessary. I'd like to understand the underlying &quot;problem&quot;.</p>
  <p>I have also looked at CurrentTraceContext in the Reactor Subscription Context and see that it answers as Tracer does.  Supporting both seems to be a threadlocal-ly supported trace context.</p>
  <p>Oddly, if I look at TraceContext in the Subscriber context, the trace, parent, and span ids are there.  It appears that WebFluxSleuthOperators.currentTraceContext(Context...) does this - so I have to believe that this is the appropriate vehicle for obtaining the trace context.</p>
  <p>So, a few questions:</p>
  <ol>
  <li><p>Is WebFluxSleuthOperators.currentTraceContext(Context...) [TraceContext in the Reactor Subscription context] the proper way to get the up-to-date trace context?</p>
  </li>
  <li><p>Looking at ReactorSleuthMethodInvocationProcessor, a reference to the current span and trace context are given to the SpanSubscriber which puts them in the Subscriber context.  As mentioned earlier, subscribe() and next() are invoked within the context of that span.  Why would a method such as a call to a r2dbc repository method effectively &quot;erase&quot; the tracer.currentSpan() but leave the trace context alone?</p>
  </li>
  </ol>
  <p>I'd love to understand this a bit more deeply and will look at the source more.  But any insight right now is greatly appreciated.  Thank you very much in advance.</p>