How to configure Sleuth to trace AWS SQS queues

Viewed 2551

I am trying to trace Spring cloud integration aws + AWS SQS app with Sleuth. The receiver receives message from SQS after a message is added to queue. The log has app name, but no trace id and span id while receiving message from sql queue. Here is a line from the log:

2017-07-28 16:24:02.352 INFO [sqs-sleuth-demo,,,] 9706 --- [enerContainer-2] com.example.demo.SQSMessageReceiver : dequeued message: hello world

I use Spring Boot '1.5.4.RELEASE' and Spring Cloud 'Dalston.SR1'. Here is the dependencies:

dependencies {

  compile("org.springframework.boot:spring-boot")
  compile("org.springframework.boot:spring-boot-starter")
  compile("org.springframework.boot:spring-boot-starter-web")

  compile("org.springframework.cloud:spring-cloud-aws-messaging")
  compile("org.springframework.cloud:spring-cloud-aws-autoconfigure")
  compile('org.springframework.cloud:spring-cloud-starter-sleuth')
  compile("org.springframework.integration:spring-integration-aws:1.0.0.RELEASE")

  compile("com.amazonaws:aws-java-sdk-sqs")
}

dependencyManagement {
  imports {
    mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
  }
}

AppConfig.java

@Configuration
public class AppConfig {

  @Value("${amazon.aws.accesskey}")
  private String amazonAWSAccessKey;

  @Value("${amazon.aws.secretkey}")
  private String amazonAWSSecretKey;

  @Value("${amazon.sqs.endpoint}")
  private String amazonSqsEndpoint;

  @Value("${cloud.aws.region.static}")
  private String awsRegion;

  @Bean
  @Primary
  public AWSCredentialsProviderChain credentialsProviderChain() {

    return new DefaultAWSCredentialsProviderChain();
  }
}

SQSMessageReceiver.java

@Component
public class SQSMessageReceiver {

  private static final Logger LOGGER = LoggerFactory.getLogger(SQSMessageReceiver.class);

  @Autowired
  private RestTemplate restTemplate;

  @SqsListener(value="${amazon.sqs.queue.name}", deletionPolicy = SqsMessageDeletionPolicy.ON_SUCCESS)

  public void receive(String message) throws Exception {

    LOGGER.info("dequeued message: " + message);

  }
}

and, DemoApplication.java

@SpringBootApplication
@EnableSqs
public class DemoApplication {

  private static final Logger LOGGER = LoggerFactory.getLogger(DemoApplication.class);

  public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);

  }
}

Is it possible to trace SQS events with Sleuth or anything wrong with the setting/code?

Thanks,

0 Answers
Related