2

I've an ECS cluster running Fargate instances with Springboot apps & want to enable tracing with least number of code changes. There're the two approaches I started looking at:

  1. Use AWS-Xray : Steps -> Add dependencies, add aWSXRayServletFilter, run X-Ray daemon in a separate container.

  2. Use Spring Cloud Sleuth : Steps -> Add dependency & property, integrate with X-Ray

So the second approach saves you number of steps in modifying your code, the issues is I couldn't find any good doc to integrate Spring Cloud Sleuth with X-Ray, can anyone point me to correct direction?

I tried reading number of docs including: https://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html

3 Answers3

2

I came across this when looking for a solution for option two. AFAIK, you still have to use the X-Ray daemon. I had to look across multiple GitHub repos and issues to solve the problem so am providing the solution here.

I used Gradle for my solution but this can be easily translated to Maven as well.

Add the BOM for spring cloud

dependencyManagement {
    imports {
        mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.3")
    }
}

Add the following dependencies to the project.

implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
implementation 'org.springframework.cloud:spring-cloud-sleuth-zipkin'
implementation 'io.zipkin.aws:zipkin-reporter-xray-udp:0.23.4'

Then Add configuration to define the Bean which is used for reporting to the X-Ray daemon.

@Configuration
public class TracingConfiguration {

  @Bean(ZipkinAutoConfiguration.REPORTER_BEAN_NAME)
  Reporter<Span> reporter() {
    return XRayUDPReporter.create();
  }
}

Define the propagation type as aws for Sleuth as per the documentation.

spring.sleuth.propagation.type=aws
Bhavik Kumar
  • 21
  • 1
  • 4
  • I already did the above but I can not see the sleuth trace id and span id in Xray, where I can find those info? – Mostafa Hassan Jul 25 '22 at 19:40
  • You should see it in your application logs and in AWS X-Ray. If you cannot see it in X-Ray then I would run the X-Ray daemon locally in debug mode to see if it is receiving the traces from your application and forwarding them to AWS X-Ray – Bhavik Kumar Jul 26 '22 at 07:56
0

I haven't tried it yet, but from the documentation you can combine the following

An amazon/aws-xray-daemon

zipkin-aws with the experimental X-Ray Storage. They have a Docker image for zipkin-aws. You need to point it to the XRay daemon. This will be running as a Zipkin server listening on port 9411.

Then you use Spring Cloud Sleuth's instrumentation and AsyncZipkinSender.

By doing this approach, you can decouple yourself from AWS as long as you have a different zipkin server.

Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265
-1

currently AWS X-Ray SDK doesn't have integration with Spring Cloud Sleuth. In order to using AWS X-Ray, the first approach would be the best way to do it.

lulu
  • 19
  • 1
  • What does that mean the first approach would be the best way to do it? can you please elaborate? – Eric May 06 '21 at 07:14