Bhupendra Chaudhary
Bhupendra Chaudhary

Reputation: 63

Integrating SpringCloudSleuth With AWS X-Ray

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

Upvotes: 2

Views: 7368

Answers (3)

Bhavik Kumar
Bhavik Kumar

Reputation: 21

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

Upvotes: 2

Archimedes Trajano
Archimedes Trajano

Reputation: 41700

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.

Upvotes: 0

lulu
lulu

Reputation: 19

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.

Upvotes: -1

Related Questions