title: How do I get the current Trace ID in a Spring Cloud Gateway GlobalFilter
body: <p>Similar to <a href="https://stackoverflow.com/questions/57427119/spring-cloud-sleuth-get-current-traceid">Spring Cloud Sleuth- Get current traceId?</a> but in the context of Spring Cloud Gateway GlobalFilter</p>
  <p>I tried to inject Tracing and get the currentTracingContext but it returns <code>null</code> when I get the current tracing context.</p>
  <pre><code>    @Autowired
      private Tracing tracing;
  
      @Override
      public Mono&lt;Void&gt; filter(final ServerWebExchange exchange, GatewayFilterChain chain) {
  
          final long startNanos = System.nanoTime();
          System.out.println(tracing.currentTraceContext().get()); // NULL
          return chain
              .filter(exchange)
              .then(
                  Mono.fromRunnable(() -&gt; {
                      System.out.println(tracing.currentTraceContext().get()); // NULL
                     ...
  </code></pre>
  <p>I am suspecting it is an <code>order</code> issue, my filter doesn't specify any <code>@Order</code>.  However, I tried both HIGHEST_PRECEDENCE and LOWEST_PRECEDENCE, still returns null.</p>