You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "darknesstm (via GitHub)" <gi...@apache.org> on 2023/05/26 13:15:50 UTC

[GitHub] [skywalking-java] darknesstm opened a new pull request, #539: Support access the sky-walking tracer context in spring gateway filter

darknesstm opened a new pull request, #539:
URL: https://github.com/apache/skywalking-java/pull/539

   <!--
       ⚠️ Please make sure to read this template first, pull requests that don't accord with this template
       maybe closed without notice.
       Texts surrounded by `<` and `>` are meant to be replaced by you, e.g. <framework name>, <issue number>.
       Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]`
   -->
   
   <!-- ==== 🐛 Remove this line WHEN AND ONLY WHEN you're fixing a bug, follow the checklist 👇 ====
   ### Fix <bug description or the bug issue number or bug issue link>
   - [ ] Add a unit test to verify that the fix works.
   - [ ] Explain briefly why the bug exists and how to fix it.
        ==== 🐛 Remove this line WHEN AND ONLY WHEN you're fixing a bug, follow the checklist 👆 ==== -->
   
   <!-- ==== 🔌 Remove this line WHEN AND ONLY WHEN you're adding a new plugin, follow the checklist 👇 ====
   ### Add an agent plugin to support <framework name>
   - [ ] Add a test case for the new plugin, refer to [the doc](https://github.com/apache/skywalking-java/blob/main/docs/en/setup/service-agent/java-agent/Plugin-test.md)
   - [ ] Add a component id in [the component-libraries.yml](https://github.com/apache/skywalking/blob/master/oap-server/server-starter/src/main/resources/component-libraries.yml)
   - [ ] Add a logo in [the UI repo](https://github.com/apache/skywalking-rocketbot-ui/tree/master/src/views/components/topology/assets)
        ==== 🔌 Remove this line WHEN AND ONLY WHEN you're adding a new plugin, follow the checklist 👆 ==== -->
   
   <!-- ==== 📈 Remove this line WHEN AND ONLY WHEN you're improving the performance, follow the checklist 👇 ====
   ### Improve the performance of <class or module or ...>
   - [ ] Add a benchmark for the improvement, refer to [the existing ones](https://github.com/apache/skywalking-java/blob/main/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/LinkedArrayBenchmark.java)
   - [ ] The benchmark result.
   ```text
   <Paste the benchmark results here>
   ```
   - [ ] Links/URLs to the theory proof or discussion articles/blogs. <links/URLs here>
        ==== 📈 Remove this line WHEN AND ONLY WHEN you're improving the performance, follow the checklist 👆 ==== -->
   
   ### <Feature description>
   - [ ] If this is non-trivial feature, paste the links/URLs to the design doc.
   - [x] Update the documentation to include this new feature.
   - [ ] Tests(including UT, IT, E2E) are added to verify the new feature.
   - [ ] If it's UI related, attach the screenshots below.
   
   - [ ] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<issue number>.
   - [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-java/blob/main/CHANGES.md).
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] darknesstm commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "darknesstm (via GitHub)" <gi...@apache.org>.
darknesstm commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1622776519

   > > You need to resolve conflicts before we can run the CI
   > 
   > There was no conflict, still not working.
   
   My Github Actions now works normally...


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] darknesstm commented on a diff in pull request #539: Support access the tracer context in spring gateway filter

Posted by "darknesstm (via GitHub)" <gi...@apache.org>.
darknesstm commented on code in PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#discussion_r1255088679


##########
apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingTraceContextActivation.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.toolkit.activation.webflux;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+
+/**
+ */

Review Comment:
   I will delete this



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] darknesstm commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "darknesstm (via GitHub)" <gi...@apache.org>.
darknesstm commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1568559261

   > I am not sure why, but this PR doesn't drive CI running.
   
   I also see the same problem in #541


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] darknesstm commented on a diff in pull request #539: Support access the tracer context in spring gateway filter

Posted by "darknesstm (via GitHub)" <gi...@apache.org>.
darknesstm commented on code in PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#discussion_r1255089761


##########
apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingStaticMethodsAroundInterceptor.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.toolkit.activation.webflux;
+
+import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.ServerWebExchangeDecorator;
+import org.springframework.web.server.adapter.DefaultServerWebExchange;
+
+import java.util.Optional;
+
+public abstract class WebFluxSkyWalkingStaticMethodsAroundInterceptor implements StaticMethodsAroundInterceptor {
+
+    protected static EnhancedInstance getInstance(Object o) {

Review Comment:
   purpose was to serve as a internal-use static method



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1622977118

   Could you rebase your commits, 14 commits for now...


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #539: Support access the sky-walking tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#discussion_r1206809177


##########
CHANGES.md:
##########
@@ -19,6 +19,7 @@ Release Notes.
 * Fix possible IllegalStateException when using Micrometer.
 * Support Grizzly Work ThreadPool Metric Monitor
 * Fix the gson dependency in the kafka-reporter-plugin.
+* Support access the sky-walking tracer context in spring gateway filter

Review Comment:
   ```suggestion
   * Support access the tracer context in the spring gateway filter
   ```



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#discussion_r1254022639


##########
apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingStaticMethodsAroundInterceptor.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.toolkit.activation.webflux;
+
+import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.ServerWebExchangeDecorator;
+import org.springframework.web.server.adapter.DefaultServerWebExchange;
+
+import java.util.Optional;
+
+public abstract class WebFluxSkyWalkingStaticMethodsAroundInterceptor implements StaticMethodsAroundInterceptor {
+
+    protected static EnhancedInstance getInstance(Object o) {

Review Comment:
   As protected, why `static`?



##########
apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingStaticMethodsAroundInterceptor.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.toolkit.activation.webflux;
+
+import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.ServerWebExchangeDecorator;
+import org.springframework.web.server.adapter.DefaultServerWebExchange;
+
+import java.util.Optional;
+
+public abstract class WebFluxSkyWalkingStaticMethodsAroundInterceptor implements StaticMethodsAroundInterceptor {
+
+    protected static EnhancedInstance getInstance(Object o) {
+        EnhancedInstance instance = null;
+        if (o instanceof DefaultServerWebExchange && o instanceof EnhancedInstance) {
+            instance = (EnhancedInstance) o;
+        } else if (o instanceof ServerWebExchangeDecorator) {
+            ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate();
+            return getInstance(delegate);
+        }
+        return instance;
+    }
+
+    protected static ContextSnapshot getContextSnapshot(Object o) {

Review Comment:
   Same here.



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#discussion_r1254021069


##########
apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingTraceContextActivation.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.toolkit.activation.webflux;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+
+/**
+ */

Review Comment:
   Are you trying to write something?



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1567737477

   I am not sure why, but this PR doesn't drive CI running.


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1568592741

   No, it isn't. That PR is waiting for maintainers' approval to run. But your PR doesn't.
   
   Yours
   <img width="881" alt="image" src="https://github.com/apache/skywalking-java/assets/5441976/437b7396-367a-4b54-9a03-10efda9f0984">
   
   That PR
   <img width="881" alt="image" src="https://github.com/apache/skywalking-java/assets/5441976/a9ecf99b-f55f-4fe6-aa2a-464d38ca7e39">
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wuwen5 commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "wuwen5 (via GitHub)" <gi...@apache.org>.
wuwen5 commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1623863266

   BTW , If the feature of https://github.com/apache/skywalking/issues/10862 is implemented with minimal modifications, it seems that only the `putCorrelation` method needs to be implemented, as the current `WebFluxSkyWalkingOperators` + `TraceContext` can support read operations.
   
   e.g.
   ```
   public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
   
           ServerHttpRequest buildRequest = exchange.getRequest()
                   .mutate()
                   .headers(httpHeaders -> WebFluxSkyWalkingOperators.continueTracing(exchange, () -> {
                       httpHeaders.add("x-trace-id", TraceContext.traceId());
                       httpHeaders.add("x-segment-id", TraceContext.segmentId());
                       httpHeaders.add("x-span-id", String.valueOf(TraceContext.spanId()));
                   }))
                   .build();
           return chain.filter(exchange.mutate().request(buildRequest).build());
       }
   ```


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1625111376

   > In this context WebFluxSkyWalkingOperators.continueTracing will add a meaningless LocalSpan
   
   Make sense. You are correct. Keep what you have built. But please update others accordingly.


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1572020938

   > You need to resolve conflicts before we can run the CI
   
   There was no conflict, still not working.


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1564472188

   Hi, this feature should be good. But you instrument a lot of things, could you try to put a doc about why you are instrumenting? And why there are so many things have to be done?


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] darknesstm commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "darknesstm (via GitHub)" <gi...@apache.org>.
darknesstm commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1565191895

   > Hi, this feature should be good. But you instrument a lot of things, could you try to put a doc about why you are instrumenting? And why there are so many things have to be done?
   
   I add a [Feature] issues linked to this.
   The source is mainly based on the relevant source of `apm-toolkit-trace`, with some simple modifications.
   
   
   
   


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng merged pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng merged PR #539:
URL: https://github.com/apache/skywalking-java/pull/539


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] kezhenxu94 commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "kezhenxu94 (via GitHub)" <gi...@apache.org>.
kezhenxu94 commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1571831507

   You need to resolve conflicts before we can run the CI


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] darknesstm commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "darknesstm (via GitHub)" <gi...@apache.org>.
darknesstm commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1568606725

   It may be that the github actions of my account were banned before, and I didn't continue to pay attention without much impact, so I will submitted the a ticket and deal with that.


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#discussion_r1254020590


##########
apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingSegmentIDInterceptor.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.toolkit.activation.webflux;
+
+import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
+import org.apache.skywalking.apm.agent.core.logging.api.ILog;
+import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+
+import java.lang.reflect.Method;
+
+public class WebFluxSkyWalkingSegmentIDInterceptor extends WebFluxSkyWalkingStaticMethodsAroundInterceptor {
+
+    private static final ILog LOGGER = LogManager.getLogger(WebFluxSkyWalkingSegmentIDInterceptor.class);
+
+    @Override
+    public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,
+                             MethodInterceptResult result) {
+        final ContextSnapshot contextSnapshot = getContextSnapshot(allArguments[0]);
+        if (contextSnapshot == null || contextSnapshot.getCorrelationContext() == null) {
+            return;
+        }
+        result.defineReturnValue(contextSnapshot.getTraceSegmentId());
+    }
+
+    @Override
+    public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,
+                              Object ret) {
+        return ret;
+    }
+
+    @Override
+    public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,
+                                      Throwable t) {
+        LOGGER.error("Failed to getDefault segment Id.", t);

Review Comment:
   What is `default` segment ID? Anything not default?



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] darknesstm commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "darknesstm (via GitHub)" <gi...@apache.org>.
darknesstm commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1624501639

   
   
   
   > BTW , If the feature of [apache/skywalking#10862](https://github.com/apache/skywalking/issues/10862) is implemented with minimal modifications, it seems that only the `putCorrelation` method needs to be implemented, as the current `WebFluxSkyWalkingOperators` + `TraceContext` can support read operations.
   > 
   > e.g.
   > 
   > ```
   > public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
   > 
   >         ServerHttpRequest buildRequest = exchange.getRequest()
   >                 .mutate()
   >                 .headers(httpHeaders -> WebFluxSkyWalkingOperators.continueTracing(exchange, () -> {
   >                     httpHeaders.add("x-trace-id", TraceContext.traceId());
   >                     httpHeaders.add("x-segment-id", TraceContext.segmentId());
   >                     httpHeaders.add("x-span-id", String.valueOf(TraceContext.spanId()));
   >                 }))
   >                 .build();
   >         return chain.filter(exchange.mutate().request(buildRequest).build());
   >     }
   > ```
   
   In this context `WebFluxSkyWalkingOperators.continueTracing` will add a meaningless LocalSpan


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#issuecomment-1623866498

   Good catch. @darknesstm Let's minimal the changes.


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #539: Support access the tracer context in spring gateway filter

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #539:
URL: https://github.com/apache/skywalking-java/pull/539#discussion_r1254039721


##########
docs/en/setup/service-agent/java-agent/Application-toolkit-webflux.md:
##########
@@ -46,6 +52,28 @@
 ...
 ```
 
+### Fetch trace context relative IDs 
+```java
+    @Override
+    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain){
+        // fetch trace ID
+        String traceId = WebFluxSkyWalkingTraceContext.traceId(exchange);

Review Comment:
   Please update all APIs you added. This is an official doc, we should provide a complete version.



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org