0

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

Harshit Gupta
  • 167
  • 1
  • 1
  • 10
  • Please read this document https://stackoverflow.com/help/how-to-ask on how to ask a good question. You have provided absolutely no meaningful information to help you. – Marcin Grzejszczak Dec 08 '20 at 12:51
  • Hi @MarcinGrzejszczak I think people who are aware of spring-cloud-sleuth and java would be able to understand what is the issue. Thanks for checking my question, In my request headers, I am providing the given value in `X-B3-TraceId` and this is the error I am getting from TraceFilter. – Harshit Gupta Dec 08 '20 at 14:00
  • I am the maintainer of Spring Cloud Sleuth and I don't understand your problem. Not to mention that you haven't provided what you're doing, how you're doing it, which version of Sleuth you have nor which version of Boot. There's no concrete information passed. – Marcin Grzejszczak Dec 08 '20 at 14:12
  • I am using spring boot 1.5.13.RELEASE with spring-cloud-sleuth-core/1.3.4.RELEASE – Harshit Gupta Dec 08 '20 at 14:50
  • 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 I am getting the above Exception. – Harshit Gupta Dec 08 '20 at 14:52
  • This version is not supported. Please upgrade to the latest version and fix the description because in its current form this question should be closed – Marcin Grzejszczak Dec 08 '20 at 15:49
  • @MarcinGrzejszczak is this issue resolved in the latest version? – Harshit Gupta Dec 08 '20 at 15:54

0 Answers0