Skip to content
Discussion options

You must be logged in to vote

@hgaong TraceContext.putCorrelation("xx", "xx") need an active span in current thread. In custom gateway filter, it does not exist.

spring-cloud-gateway use webflux, it propagate tracingcontext by dynamicfield on ServerWebExchange, you can change your code like this:

@Component
public class AuthFilter implements GlobalFilter, Ordered {

    @Override
    public Mono<Void> filter(final ServerWebExchange exchange, final GatewayFilterChain chain) {
   ---> WebFluxSkyWalkingTraceContext.putCorrelation(exchange, "user","xxx");
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}

WebFluxSkyWalkingTraceContext provided by apm-toolkit-…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@hgaong
Comment options

@wu-sheng
Comment options

wu-sheng Oct 3, 2023
Collaborator

Comment options

You must be logged in to vote
1 reply
@wu-sheng
Comment options

wu-sheng Oct 3, 2023
Collaborator

Comment options

You must be logged in to vote
0 replies
Answer selected by hgaong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants