aws / aws/aws-xray-java-agent

FR: Support for Spring WebClient

Open
#87 1 comment 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
46
Forks
20
PR merge metrics
No merged PRs in 30d

Description

### FR: Support for Spring WebClient
In my sample application using Spring WebClient with X-Ray Java agent auto-instrumentation, the trace header is not injected into the http header.

This is the code block for the downstream http call using Spring webclient
```java
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@Slf4j
public class GoodbyeController {

private final WebClient additionWebClient;

@GetMapping("/goodbye")
public ResponseEntity goodbye() throws InterruptedException {

MathResult addResult =
this.additionWebClient
.get()
.uri(
uri ->
uri.path("/add")
.queryParam("x", Long.toString(x))
.queryParam("y", Long.toString(y))
.build())
.retrieve()
.bodyToMono(MathResult.class)
.block();
}
}
```

In the downstream http request handler, I printed out the request header and found that no trace id,

`
2021-03-04 16:19:18.841 INFO [Addition App,604108865e2cf420e5d967d9c6dc0ec3,e5d967d9c6dc0ec3,true] 25 --- [nio-8080-exec-8] c.g.t.s.tracingpoc.AdditionController : Starting to add... x: [100], y: [1000]. RequestHeaders: [{accept-encoding=gzip, user-agent=ReactorNetty/0.9.8.RELEASE, host=:8080, accept=*/*}]
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.