Similar to Spring Cloud Sleuth- Get current traceId? but in the context of Spring Cloud Gateway GlobalFilter
I tried to inject Tracing and get the currentTracingContext but it returns null
when I get the current tracing context.
@Autowired
private Tracing tracing;
@Override
public Mono<Void> 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(() -> {
System.out.println(tracing.currentTraceContext().get()); // NULL
...
I am suspecting it is an order
issue, my filter doesn't specify any @Order
. However, I tried both HIGHEST_PRECEDENCE and LOWEST_PRECEDENCE, still returns null.