You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "xzyJavaX (via GitHub)" <gi...@apache.org> on 2023/02/28 10:51:28 UTC

[GitHub] [skywalking-java] xzyJavaX opened a new pull request, #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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

   <!--
       ⚠️ 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 👆 ==== -->
   
   <!-- ==== 🆕 Remove this line WHEN AND ONLY WHEN you're adding a new feature, follow the checklist 👇 ====
   ### <Feature description>
   - [ ] If this is non-trivial feature, paste the links/URLs to the design doc.
   - [ ] 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.
        ==== 🆕 Remove this line WHEN AND ONLY WHEN you're adding a new feature, follow the checklist 👆 ==== -->
   
   - [ ] 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] wu-sheng commented on pull request #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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

   Somehow Spring 6 case fails? Could you recheck?


-- 
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 #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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


##########
apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java:
##########
@@ -82,9 +75,9 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
         HttpServletResponse response = (HttpServletResponse) allArguments[1];
 
         AbstractSpan span = ContextManager.activeSpan();
-        if (IS_SERVLET_GET_STATUS_METHOD_EXIST && response.getStatus() >= 400) {
+        Tags.HTTP_RESPONSE_STATUS_CODE.set(span, response.getStatus());
+        if (response.getStatus() >= 400) {

Review Comment:
   It is better to debug this logic.



-- 
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 #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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

   > > Somehow Spring 6 case fails? Could you recheck?
   > 
   > The only issue I could find is that we expected `POST:/create` call returns status code 200, but in the actual data is 201.
   > 
   > But I don't think this PR is relevant. Since for `EntrySpan`, the tag is set when `stackDepth == currentMaxDepth`. This means only the Spring plugin can set tags.
   
   
   This is somewhat relevant, I tested Spring 6 and expected the status code to be 201 but it was always 200, I was sure it was not an issue of Spring plugin but didn't dig deeper to the cause, so this PR accidentally fixes the bug too, so, please update the expected data for Spring 6, change status code from 200 to 201.


-- 
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] lujiajing1126 commented on pull request #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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

   > Somehow Spring 6 case fails? Could you recheck?
   
   The only issue I could find is that we expected `POST:/create` call returns status code 200, but in the actual data is 201.
   
   But I don't think this PR is relevant since for `EntrySpan`, the tag is set when `stackDepth == currentMaxDepth`. This means only the Spring plugin can set tags.
   
   @kezhenxu94 @wu-sheng any idea?


-- 
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] xzyJavaX commented on pull request #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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

   https://github.com/apache/skywalking-java/pull/286/files#r1119753555


-- 
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 #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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

   What do these 201 and 204 mean actually?


-- 
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 #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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


-- 
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] lujiajing1126 commented on a diff in pull request #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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


##########
apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java:
##########
@@ -82,9 +75,9 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
         HttpServletResponse response = (HttpServletResponse) allArguments[1];
 
         AbstractSpan span = ContextManager.activeSpan();
-        if (IS_SERVLET_GET_STATUS_METHOD_EXIST && response.getStatus() >= 400) {
+        Tags.HTTP_RESPONSE_STATUS_CODE.set(span, response.getStatus());
+        if (response.getStatus() >= 400) {

Review Comment:
   > I think this fixes the issue I mentioned
   
   But in the `EntrySpan`,
   
   ```java
       @Override
       public EntrySpan tag(String key, String value) {
           if (stackDepth == currentMaxDepth || isInAsyncMode) {
               super.tag(key, value);
           }
           return this;
       }
   ```
   
   I suppose in the Tomcat plugin, the condition cannot be true. Do I miss 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] kezhenxu94 commented on a diff in pull request #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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


##########
apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java:
##########
@@ -82,9 +75,9 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
         HttpServletResponse response = (HttpServletResponse) allArguments[1];
 
         AbstractSpan span = ContextManager.activeSpan();
-        if (IS_SERVLET_GET_STATUS_METHOD_EXIST && response.getStatus() >= 400) {
+        Tags.HTTP_RESPONSE_STATUS_CODE.set(span, response.getStatus());
+        if (response.getStatus() >= 400) {

Review Comment:
   I think this fixes the issue I mentioned



-- 
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] lujiajing1126 commented on a diff in pull request #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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


##########
apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java:
##########
@@ -82,9 +75,9 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
         HttpServletResponse response = (HttpServletResponse) allArguments[1];
 
         AbstractSpan span = ContextManager.activeSpan();
-        if (IS_SERVLET_GET_STATUS_METHOD_EXIST && response.getStatus() >= 400) {
+        Tags.HTTP_RESPONSE_STATUS_CODE.set(span, response.getStatus());
+        if (response.getStatus() >= 400) {

Review Comment:
   ![image](https://user-images.githubusercontent.com/2568208/222691111-56d8dee0-6c58-4ca6-b908-b961ac16cac1.png)
   
   After debugging, it seems that the above method is not called. Instead, `public AbstractTracingSpan tag(AbstractTag<?> tag, String value)` is called while `EntrySpan` does not override this method (But `ExitSpan` does!). Then the `http.status_code` tag is set.
   
   I am not sure if it is a feature or a bug? @wu-sheng @kezhenxu94 



-- 
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] lujiajing1126 commented on a diff in pull request #466: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x

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


##########
apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java:
##########
@@ -82,9 +75,9 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
         HttpServletResponse response = (HttpServletResponse) allArguments[1];
 
         AbstractSpan span = ContextManager.activeSpan();
-        if (IS_SERVLET_GET_STATUS_METHOD_EXIST && response.getStatus() >= 400) {
+        Tags.HTTP_RESPONSE_STATUS_CODE.set(span, response.getStatus());
+        if (response.getStatus() >= 400) {

Review Comment:
   Another question is why Tomcat and Spring set different status code...



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