spring-bootresttemplateaws-xray

Configure RestTemplate for AWS X-Ray


How to configure the RestTemplate to use the http client provided in the AWS X-Ray SDK ?

I found an example with Spring version 2.3.4: https://github.com/aws/aws-xray-sdk-java/issues/220 .

But I use Spring Boot version 3.1.0 and the example doesn't even compile.


Solution

  • You can try the OpenTelemetry Java SDK since it provides instrumentation for RestTemplates with Spring 3.1+ https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-web/spring-web-3.1/library

    OpenTelemetry works with X-Ray via the AWS Distribution of OpenTelemetry. Pease see here to get started: https://aws-otel.github.io/docs/getting-started/java-sdk