yqw570994511 commented on PR #736:
URL: https://github.com/apache/skywalking-java/pull/736#issuecomment-2536090005

   > I think the issue seems to be repetitive with this #539 , and we can 
support it in this way.
   > 
   > 
https://github.com/apache/skywalking-java/blob/main/docs/en/setup/service-agent/java-agent/Application-toolkit-webflux.md#fetch-trace-context-relative-ids
   > 
   > ```
   > @Override
   >     public Mono<Void> filter(ServerWebExchange exchange, 
GatewayFilterChain chain){
   >         // fetch trace ID
   >         String traceId = WebFluxSkyWalkingTraceContext.traceId(exchange);
   >         
   >         // fetch segment ID
   >         String segmentId = 
WebFluxSkyWalkingTraceContext.segmentId(exchange);
   >         
   >         // fetch span ID
   >         int spanId = WebFluxSkyWalkingTraceContext.spanId(exchange);
   >         
   >         return chain.filter(exchange);
   >     }
   > ```
   
   I tried it according to the method you gave, and it achieved the same effect 
as my previous code:
   
   <img width="818" alt="image" 
src="https://github.com/user-attachments/assets/9813626b-f864-4a2f-8d19-5e31020c810b";
 />
   
   
   I got the following result:
   
   <img width="1370" alt="image" 
src="https://github.com/user-attachments/assets/5876fb36-f436-4b29-80c9-f31d24144561";
 />
   
   
   But when I am in another situation, it can't meet my needs. 
   My project is configured with logback to output skywalking's traceId to help 
me track problems, but using the above method, I can see that skywalking's 
traceId is not output. 
   In the production environment, I really need my log to print out the 
traceId, and I also hope that I can achieve this goal by writing business code 
as much as possible. For example, I hope my filter code can output the traceId 
in the log like this:
   
   <img width="743" alt="image" 
src="https://github.com/user-attachments/assets/67060889-6f1c-4a77-97ab-48329e76773a";
 />
   
   
   The result of using the new solution is as follows:
   
   <img width="1420" alt="image" 
src="https://github.com/user-attachments/assets/208ce4f1-997b-4207-947a-b383b7b76421";
 />
   
   I think the new scheme can support more scenarios and should help many 
people like me who have similar needs.
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to