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 2020/07/15 16:20:36 UTC
[GitHub] [skywalking] ascrutae commented on a change in pull request #5086: Add support for spring webclient
ascrutae commented on a change in pull request #5086:
URL: https://github.com/apache/skywalking/pull/5086#discussion_r455172724
##########
File path: test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/controller/TestWebclientController.java
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.testcase.sc.webflux.projectB.controller;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.reactive.function.client.ExchangeStrategies;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
+
+@RestController
+public class TestWebclientController {
+
+ @Value("${projectB.host:localhost:18080}")
+ private String hostBAddress;
+
+ @RequestMapping("/testcase/webclient/ping")
+ public String ping() {
+ return "ok";
+ }
+
+ @RequestMapping("/testcase/webclient/test1")
+ public String test1() {
+ Mono<String> resp = WebClient.builder().exchangeStrategies(ExchangeStrategies.builder()
+ .build())
+ .build()
+ .get().uri("http://" + hostBAddress + "/testcase/webclient/ping")
Review comment:
It's still not link because Controller and WebClient calling run in different threads and the WebClient plugin doesn't link the trace context. I suggest that you should save the `ContextSnapshot` when create WebClient Object and `continued` when WebClient send request.
I also found another problem that the trace miss span about WebClient plugin, In my case, the trace will miss the database span.
```java
@RequestMapping("/testcase/webclient/test1")
public String test1() {
Mono<String> resp = WebClient.builder().exchangeStrategies(ExchangeStrategies.builder()
.build())
.build()
.get().uri("http://" + hostBAddress + "/testcase/webclient/ping")
.retrieve().bodyToMono(String.class);
resp.subscribe(new Consumer<String>() {
@Override
public void accept(final String s) {
// read data from database
}
});
return "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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org