Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
darknesstm opened this issue May 27, 2023 · 4 comments
Closed
3 tasks done
Assignees
Labels
agent Language agent related. feature New feature java Java agent related
Milestone

Comments

@darknesstm
Copy link

darknesstm commented May 27, 2023

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

@darknesstm darknesstm added the feature New feature label May 27, 2023
@wu-sheng wu-sheng added agent Language agent related. java Java agent related labels May 27, 2023
@wu-sheng wu-sheng added this to the Java - 8.16.0 milestone May 27, 2023
@wu-sheng
Copy link
Member

Hi, I knew what is the use case. What I don't follow up on is why the code changes are so huge. Many new things are added.
Here are two things at least should be done

  1. We need a proposal to explain what exactly you changed.
  2. We need a plugin test to verify this propagation of collaboration context is working. A -> Gateway -> B for example, you should build a collaboration context in A, and check that in B, also tag it in the test. Then the plugin test tool could verify it.

@darknesstm
Copy link
Author

In the latest commit, I have added plugin test cases and passed it in local.

then, so where should I write this proposal?

@wu-sheng wu-sheng removed this from the Java - 8.16.0 milestone May 31, 2023
@wu-sheng
Copy link
Member

Remove from next release, as we can't verify CI due to the contributor account issue.

@wu-sheng wu-sheng added this to the Java - 9.0.0 milestone Jul 7, 2023
@wu-sheng
Copy link
Member

apache/skywalking-java#539 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent Language agent related. feature New feature java Java agent related
Projects
None yet
Development

No branches or pull requests

2 participants