I have a service A which calls my service B which is on spring boot. Service A passes a request header with key X-B3-TraceId and value 1f99a12d-066e-4aac-a71a-e7d42d7fa7a3 but the sleuth gives the following exception:
2020-12-08 20:18:21,821 [XNIO-2 task-5] ERROR [org.springframework.cloud.sleuth.instrument.web.ZipkinHttpSpanExtractor] [ZipkinHttpSpanExtractor.java:50] [trace=,span=] - Exception occurred while trying to extract span from carrier
java.lang.IllegalArgumentException: Malformed id: 1f99a12d-066e-4aac-a71a-e7d42d7fa7a3
at org.springframework.cloud.sleuth.Span.hexToId(Span.java:585)
at org.springframework.cloud.sleuth.instrument.web.ZipkinHttpSpanExtractor.buildParentSpan(ZipkinHttpSpanExtractor.java:90)
at org.springframework.cloud.sleuth.instrument.web.ZipkinHttpSpanExtractor.joinTrace(ZipkinHttpSpanExtractor.java:48)
at org.springframework.cloud.sleuth.instrument.web.ZipkinHttpSpanExtractor.joinTrace(ZipkinHttpSpanExtractor.java:19)
at org.springframework.cloud.sleuth.instrument.web.TraceFilter.createSpan(TraceFilter.java:375)
at org.springframework.cloud.sleuth.instrument.web.TraceFilter.doFilter(TraceFilter.java:165)
From Span class I think traceId can only include 0-9 and a-f
public static long hexToId(String lowerHex, int index) {
Assert.hasText(lowerHex, "Can't convert empty hex string to long");
long result = 0L;
for(int endIndex = Math.min(index + 16, lowerHex.length()); index < endIndex; ++index) {
char c = lowerHex.charAt(index);
result <<= 4;
if (c >= '0' && c <= '9') {
result |= (long)(c - 48);
} else {
if (c < 'a' || c > 'f') {
throw new IllegalArgumentException("Malformed id: " + lowerHex);
}
result |= (long)(c - 97 + 10);
}
}
return result;
}
Any way to make the trace id generic?
I am using spring boot 1.5.13.RELEASE with spring-cloud-sleuth-core/1.3.4.RELEASE