In my spring boot project, TraceId missing only inside @SqsListener annotated method.
I have used spring-cloud-starter-sleuth
for logging and logback configuration.
Hey even it was not working for 1.2.5 version of sleuth
so i made some changes - these are manual changes for tracer and span id
@SqsListener(value = "test", deletionPolicy = SqsMessageDeletionPolicy.ON_SUCCESS)
public void process(final String message) {
String traceId = MDC.get("traceId");
Span span = tracer.createSpan(traceId);
LOGGER.info("Request for : " + message);
try {
// System user and your working stuff
tracer.close();
return;
} catch (Exception e) {
ThreadLocalUtil.resetRequestInitiator();
LOGGER.error("Exception in message", e);
}
throw new ErrorProcessSQS("Exception in message");
}