woshishitou commented on issue #6900:
URL: https://github.com/apache/skywalking/issues/6900#issuecomment-833425033
`
package com.example.gatewaydemo.filter;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
@Configuration
public class FilterConfig {
@Bean
public GlobalFilter b() {
return new BFilter();
}
public class BFilter implements GlobalFilter, Ordered {
@Override
public Mono<Void> filter(ServerWebExchange exchange,
GatewayFilterChain chain) {
// The value here is N/A
exchange.getResponse().getHeaders().set("tid",
TraceContext.traceId());
return chain.filter(exchange).then(Mono.fromRunnable(() ->
{
// The value here is also N/A
String traceId2 = TraceContext.traceId();
System.out.println("traceId:" + traceId2);
}));
}
@Override
public int getOrder() {
return 1;
}
}
}
`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]