Issue
I'm testing interservice communication with Spring Boot Rest services deployed on AWS with AppMesh and Service Discovery enabled. To be able to send messages from service a to service b I've to use the OpenFeign client to generate a proxy class.
- Spring Boot OpenFeign
- AWS XRay
- ECS
- ECR
- Sleuth
- AppMesh (Virtual Node, Virtual Service)
- AWS Service Discovery (instead of Eureka)
Expected Behavior
In AWS XRay, it should show a call trace:
Client -> ServiceA -> ServiceB
Actual Behavior
In AWS XRay, I can see the call traces:
Client -> ServiceA Client -> ServiceB
Another question would be how to tell OpenFeign to use the HttpClient from AWS SDK?
Other Information
Repository available at: https://github.com/czetsuya/lab-microservice-spring-aws
Solution
I was able to fix this issue by using a dynamicNamingStrategy in tracingFilter
@Bean
public Filter tracingFilter(final AWSXRayRecorder awsxRayRecorder) {
log.info("Setting up AWS Xray tracing filter");
return new AWSXRayServletFilter(SegmentNamingStrategy.dynamic(Optional.ofNullable(AWS_XRAY_SEGMENT_NAME).orElse(
"xray-filter")));
}
And create an HttpClientBuilder bean.
@Bean
public HttpClientBuilder xrayHttpClientBuilder() {
log.info("Setting up AWS xray http client configuration");
return HttpClientBuilder.create();
}
AWS XRay should now show the HTTP requests in the trace:
The project code is available at https://github.com/czetsuya/lab-microservice-spring-aws.
Answered By - czetsuya
Answer Checked By - Cary Denson (JavaFixing Admin)