You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/10/12 06:17:32 UTC

[GitHub] [skywalking-java] xu1009 opened a new pull request #49: Add okhttp2.x plugin

xu1009 opened a new pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49


   <!--
       ⚠️ 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 πŸ‘† ==== -->
   
   
   ### Add an agent plugin to support <framework name>
   - [x] 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 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 πŸ‘† ==== -->
   
   - [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<7889>.
   - [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 a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728805080



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       This span will be ignore only if both spans are in the same thread. But callback usually should generate a local span. Also, callback should invoke after the first HTTP span finished, right? 




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728683911



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       ok, i will remove it




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r726999560



##########
File path: test/plugin/scenarios/okhttp2-scenario/support-version.list
##########
@@ -0,0 +1,27 @@
+# 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.
+
+# lists your version here (Contains only the last version number of each minor version.)
+
+2.4.0
+2.5.0
+2.6.0
+2.7.0
+2.7.1
+2.7.2
+2.7.3
+2.7.4
+2.7.5

Review comment:
       ok




-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-946843366


   > @xu1009 Could you finish this pull request?
   
   @wu-sheng  sorry about it, i am very busy recently, i will try my best to finish it this week


-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728687835



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       it looks the passed okhttp version has the same problem, besides, the time of action in response method will be calculated in last span, it is not correct




-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950814038


   Please fix 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] wu-sheng commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950995234


   > i do not change that plugin==
   
   I know you didn't change 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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r735407097



##########
File path: CHANGES.md
##########
@@ -37,6 +37,7 @@ Release Notes.
 * Fix version compatibility for JsonRPC4J plugin.
 * Add plugin to support Apache Kylin-jdbc 2.6.x 3.x 4.x
 * Fix instrumentation v2 API doesn't work for constructor instrumentation.
+* Add plugin to support okhttp 2.x

Review comment:
       Remember to add another change log here, because you changed the plugin for other versions.




-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727656395



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       I can see `/okhttp2-scenario/case/receiveContext-0` exit span, but where is `/okhttp2-scenario/case/receiveContext-1` exit span?




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727909566



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       yes the segment  next is async call, it follows the passed okhttp version
   
   /okhttp2-scenario/case/receiveContext-1 exit span seems lost, i recheck it




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727908319



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5

Review comment:
       ok




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728771234



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       ![image](https://user-images.githubusercontent.com/22722907/137283696-b9654d1e-487d-4594-b9fb-7cf9d8e3c1cc.png)
   
   i fix it by add local span in response, so it can catch the action in reposne method and the first http call time is correct like above




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727646334



##########
File path: apm-sniffer/apm-sdk-plugin/okhttp-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v2/RealCallInterceptor.java
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.plugin.okhttp.v2;
+
+import com.squareup.okhttp.Headers;
+import com.squareup.okhttp.HttpUrl;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.context.CarrierItem;
+import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+/**
+ * {@link RealCallInterceptor} intercept the synchronous http calls by the discovery of okhttp.
+ */
+public class RealCallInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor {
+
+    private static Field FIELD_HEADERS_OF_REQUEST;
+
+    static {
+        try {
+            final Field field = Request.class.getDeclaredField("headers");
+            field.setAccessible(true);
+            FIELD_HEADERS_OF_REQUEST = field;
+        } catch (Exception ignore) {
+            FIELD_HEADERS_OF_REQUEST = null;
+        }
+    }
+
+    @Override
+    public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+        objInst.setSkyWalkingDynamicField(allArguments[1]);
+    }
+
+    /**
+     * Get the {@link Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host,
+     * port, kind, component, url from {@link Request}. Through the reflection of the way, set the http header
+     * of context data into {@link Request#headers()}.
+     *
+     * @param result change this result, if you want to truncate the method.
+     */
+    @Override
+    public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+        MethodInterceptResult result) throws Throwable {
+        Request request = (Request) objInst.getSkyWalkingDynamicField();
+
+        ContextCarrier contextCarrier = new ContextCarrier();
+        HttpUrl requestUrl = request.httpUrl();
+        AbstractSpan span = ContextManager.createExitSpan(requestUrl.uri()
+                                                                    .getPath(), contextCarrier, requestUrl.host() + ":" + requestUrl
+            .port());

Review comment:
       ok




-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728003700



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       Why do we need to test this scenario? Who will use this header key besides ourselves?




-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-940733215


   ok fix conflict


-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727676908



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5

Review comment:
       We don't have to do this. Usually `ge 0` is clear enough.




-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng merged pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49


   


-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950867186


   yes, i find the problem, fix it


-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950994623


   the master branch failed too


-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950975063


   i do not change that plugin==


-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950582627


   no, i think it is the best, it can show the time cost precisely


-- 
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 removed a comment on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng removed a comment on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950926122


   It seems netty-io case keeps failing.


-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950861408


   > the failed ci task is not my change
   
   I rerun those. But it seems you missed some UTs?


-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727654024



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       Could you explain a little about this? `sw8` header is not in this format.
   When you are doing request, the header should be injected automatically. Is this somthing special?

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       What is this segment? It seems no exit and no ref?

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5

Review comment:
       Why `ge 5`?

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       I assume this is the main entry and the next should be async call, right?

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       I can see `/okhttp2-scenario/case/receiveContext-0` exit span, but where is `/okhttp2-scenario/case/receiveContext-1` exit span?

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5

Review comment:
       We don't have to do this. Usually `ge 0` is clear enough.

##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       Why do we need to test this scenario? Who will use this header key besides ourselves?




-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r726937695



##########
File path: test/plugin/scenarios/okhttp2-scenario/support-version.list
##########
@@ -0,0 +1,27 @@
+# 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.
+
+# lists your version here (Contains only the last version number of each minor version.)
+
+2.4.0
+2.5.0
+2.6.0
+2.7.0
+2.7.1
+2.7.2
+2.7.3
+2.7.4
+2.7.5

Review comment:
       Please keep 2.7.5 only, we don't test patch version unless have to.




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728686220



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       i find the problem, the request is in async call back respose method, but the last span is exit span, this causes this span will be discarded
   
   




-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-941020485


   Your https://github.com/apache/skywalking-java/pull/45 gets merged, you have to resolve the conflicts again.


-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r735409037



##########
File path: CHANGES.md
##########
@@ -37,6 +37,7 @@ Release Notes.
 * Fix version compatibility for JsonRPC4J plugin.
 * Add plugin to support Apache Kylin-jdbc 2.6.x 3.x 4.x
 * Fix instrumentation v2 API doesn't work for constructor instrumentation.
+* Add plugin to support okhttp 2.x

Review comment:
       ok
   




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728839647



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       yes, both span is in same thread, the implementation  is strange, i will optimize it




-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-940937784


   Please resolve conflicts.


-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727646334



##########
File path: apm-sniffer/apm-sdk-plugin/okhttp-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v2/RealCallInterceptor.java
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.plugin.okhttp.v2;
+
+import com.squareup.okhttp.Headers;
+import com.squareup.okhttp.HttpUrl;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.context.CarrierItem;
+import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+/**
+ * {@link RealCallInterceptor} intercept the synchronous http calls by the discovery of okhttp.
+ */
+public class RealCallInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor {
+
+    private static Field FIELD_HEADERS_OF_REQUEST;
+
+    static {
+        try {
+            final Field field = Request.class.getDeclaredField("headers");
+            field.setAccessible(true);
+            FIELD_HEADERS_OF_REQUEST = field;
+        } catch (Exception ignore) {
+            FIELD_HEADERS_OF_REQUEST = null;
+        }
+    }
+
+    @Override
+    public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+        objInst.setSkyWalkingDynamicField(allArguments[1]);
+    }
+
+    /**
+     * Get the {@link Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host,
+     * port, kind, component, url from {@link Request}. Through the reflection of the way, set the http header
+     * of context data into {@link Request#headers()}.
+     *
+     * @param result change this result, if you want to truncate the method.
+     */
+    @Override
+    public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+        MethodInterceptResult result) throws Throwable {
+        Request request = (Request) objInst.getSkyWalkingDynamicField();
+
+        ContextCarrier contextCarrier = new ContextCarrier();
+        HttpUrl requestUrl = request.httpUrl();
+        AbstractSpan span = ContextManager.createExitSpan(requestUrl.uri()
+                                                                    .getPath(), contextCarrier, requestUrl.host() + ":" + requestUrl
+            .port());

Review comment:
       ok

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5

Review comment:
       at least one health check

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5

Review comment:
       ok

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       yes the segment  next is async call, it follows the passed okhttp version
   
   /okhttp2-scenario/case/receiveContext-1 exit span seems lost, i recheck it

##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       it can confirm the plugin overwrite the skywalking sw8 head




-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728838952



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       That is correct. But when you look at metrics of lines in the topology, which represents calling outbound to upstream, the number of client side is generated by exit span.
   So, we also need to fix that duration too.




-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950584028


   yes, i ci it in this way


-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950962555


   Strange, that plugin can't pass even I have tried many times.


-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727672450



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5

Review comment:
       at least one health check




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728840677



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       ok i will fix it and the passed okhttp version too




-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728840998



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       That means the first exit span doesn't finish in time. 




-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727654024



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       Could you explain a little about this? `sw8` header is not in this format.
   When you are doing request, the header should be injected automatically. Is this somthing special?

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       What is this segment? It seems no exit and no ref?

##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5

Review comment:
       Why `ge 5`?




-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728807017



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       A question is, from the graph, the duration of first span is incorrect. It should finish before the local span starts, otherwise, the rpc duration is over measured.




-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950577770


   ![image](https://user-images.githubusercontent.com/22722907/138645990-cf7696ea-4fe4-457d-988e-851ddc6810dc.png)
   
   i fix it like above, you think ok
   
   execute is local span,include execute http req and response callback fail callback


-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950583346


   > no, i think it is the best, it can show the time cost precisely
   
   I just mean this, there are several versions to fix, right?
   https://github.com/apache/skywalking-java/pull/49/#discussion_r728840677 


-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950981059


   i will try the master branch


-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950830901


   ok, okhttp4.x use kt, it looks internal method name is diff in running time 


-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-946469036


   @xu1009 Could you finish this pull request?


-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727910331



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       it can confirm the plugin overwrite the skywalking sw8 head




-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728837169



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       yes, but self time cost is the duration of first span,




-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728805703



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       Local span should be added. 




-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950030959


   New release should start recently, if you want to include this in, you need to finish this PR ASAP.


-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950854696


   the failed ci task is not my change


-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950926122


   It seems netty-io case keeps failing.


-- 
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 #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-950579438


   This trace seems good now. Is there other version(s) to fix?


-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727184149



##########
File path: apm-sniffer/apm-sdk-plugin/okhttp-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v2/RealCallInterceptor.java
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.plugin.okhttp.v2;
+
+import com.squareup.okhttp.Headers;
+import com.squareup.okhttp.HttpUrl;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.context.CarrierItem;
+import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+/**
+ * {@link RealCallInterceptor} intercept the synchronous http calls by the discovery of okhttp.
+ */
+public class RealCallInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor {
+
+    private static Field FIELD_HEADERS_OF_REQUEST;
+
+    static {
+        try {
+            final Field field = Request.class.getDeclaredField("headers");
+            field.setAccessible(true);
+            FIELD_HEADERS_OF_REQUEST = field;
+        } catch (Exception ignore) {
+            FIELD_HEADERS_OF_REQUEST = null;
+        }
+    }
+
+    @Override
+    public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+        objInst.setSkyWalkingDynamicField(allArguments[1]);
+    }
+
+    /**
+     * Get the {@link Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host,
+     * port, kind, component, url from {@link Request}. Through the reflection of the way, set the http header
+     * of context data into {@link Request#headers()}.
+     *
+     * @param result change this result, if you want to truncate the method.
+     */
+    @Override
+    public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+        MethodInterceptResult result) throws Throwable {
+        Request request = (Request) objInst.getSkyWalkingDynamicField();
+
+        ContextCarrier contextCarrier = new ContextCarrier();
+        HttpUrl requestUrl = request.httpUrl();
+        AbstractSpan span = ContextManager.createExitSpan(requestUrl.uri()
+                                                                    .getPath(), contextCarrier, requestUrl.host() + ":" + requestUrl
+            .port());

Review comment:
       The format of this seems a little strange, could you manually polish 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] wu-sheng commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-940714588


   Please fix conflicts.


-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-941052174


   ok, fix conflicts


-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-940956983


   ok, fix it


-- 
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] xu1009 commented on a change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r728771234



##########
File path: test/plugin/scenarios/okhttp2-scenario/src/main/java/test/apache/skywalking/apm/testcase/okhttp2/controller/CaseController.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.okhttp2.controller;
+
+import com.squareup.okhttp.Callback;
+import com.squareup.okhttp.OkHttpClient;
+import com.squareup.okhttp.Request;
+import com.squareup.okhttp.Response;
+import java.io.IOException;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/case")
+@Log4j2
+public class CaseController {
+
+    private static final String SUCCESS = "Success";
+
+    @RequestMapping("/receiveContext-1")
+    @ResponseBody
+    public String receiveContextService1() throws InterruptedException {
+        return "receiveContext-1";
+    }
+
+    @RequestMapping("/receiveContext-0")
+    @ResponseBody
+    public String receiveContextService0() throws InterruptedException {
+        return "receiveContext-0";
+    }
+
+    @RequestMapping("/okhttp2-scenario")
+    @ResponseBody
+    public String okHttpScenario() {
+        // Like gateway forward trace header.
+        Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
+                .header("sw8", "123456").build();

Review comment:
       ![image](https://user-images.githubusercontent.com/22722907/137283696-b9654d1e-487d-4594-b9fb-7cf9d8e3c1cc.png)
   
   i fix it by add local span in response, so it can catch the action in reposne method, like above




-- 
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 change in pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#discussion_r727656109



##########
File path: test/plugin/scenarios/okhttp2-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,102 @@
+# 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.
+segmentItems:
+- serviceName: okhttp2-scenario
+  segmentSize: ge 5
+  segments:
+  - segmentId: not null
+    spans:
+    - operationName: Async/okhttp2-scenario/case/receiveContext-0
+      parentSpanId: 0
+      spanId: 1
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 0
+      isError: false
+      spanType: Local
+      skipAnalysis: 'false'
+    - operationName: GET:/case/okhttp2-scenario
+      parentSpanId: -1
+      spanId: 0
+      spanLayer: Http
+      startTime: nq 0
+      endTime: nq 0
+      componentId: 14
+      isError: false
+      spanType: Entry
+      tags:
+      - {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
+      - {key: http.method, value: GET}
+      skipAnalysis: 'false'

Review comment:
       I assume this is the main entry and the next should be async call, right?




-- 
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] xu1009 commented on pull request #49: Add okhttp2.x plugin

Posted by GitBox <gi...@apache.org>.
xu1009 commented on pull request #49:
URL: https://github.com/apache/skywalking-java/pull/49#issuecomment-940805510


   it looks hbase scenarios test failed, i do not change other file


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