Skip to content

[Feature] Support access the tracer context in the spring gateway filter #10862

@darknesstm

Description

@darknesstm

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Description

In some cases, we need to determine the tenant ID of the current request based on certain information (such as domain name) in Spring Gateway. Usually, we customize a filter to implement this logic. However, after obtaining this information in the filter, due to the framework of WebFlux, it is currently impossible to directly pass it to downstream nodes through the context of SkyWalking.

Therefore, relevant tool methods are needed to process the snapshot information stored in the ServerWebExchange, so that it can be automatically injected into the context of the subsequent link through the header information "sw8-correlation".

Use case

public class  TenantHandler implements GlobalFilter {

    // ...

    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        WebFluxSkyWalkingTraceContext.putCorrelation(exchange, "TenantId", getTenantIdByDomain(exchange.getRequest()));
        // ...
    }
}

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

agentLanguage agent related.featureNew featurejavaJava agent related

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions