1
votes

I recently upgraded my project from Spring Boot 1.4.1, Spring Cloud Sleuth 1.1.0, Spring Cloud Zipkin 1.1.0 to Spring Boot 1.5.3, Spring Cloud Sleuth 1.2.0, Spring Cloud Zipkin 1.2.0.

Read that with the latest version of Spring Cloud Sleuth, they had added "error" tags which will get reported to Zipkin automatically in case of any exceptions.

I have a @ControllerAdvice class extending ResponseEntityExceptionHandler for custom exception handling. I was able to report errors to the Tracer and visualize the same in Zipkin when using the old versions (Spring Boot 1.4.1, Spring Cloud Sleuth 1.1.0, Spring Cloud Zipkin 1.1.0) using the below method:

private void reportErrorSpan(String errorDesc, String message) {
    if(tracer != null) {
        Span span = tracer.getCurrentSpan();
        span.logEvent("ERROR: " + message);
        tracer.addTag("error", errorDesc);
    }
}

After I upgraded, this doesn't seem to work and spring cloud sleuth's default error reporting was also not happening. Only after commenting out the @ControllerAdvice and letting Spring Boot's default ErrorController to handle the exceptions, I was able to visualize the errors in Zipkin. However, we need the custom exception handling to format the error response in a standard way with error codes across all our PaaS services. Is there a way to do this? Should I use any other Sleuth objects to achieve this?

1
Can you post your sample somewhere so I can debug this? That way I'll know which version of Sleuth / Boot you are using and how to replicate this. - Marcin Grzejszczak
@MarcinGrzejszczak I'm using Spring Boot 1.5.3.RELEASE and Spring Cloud Sleuth/Zipkin 1.2.0.RELEASE. I will not be able to post the actual project. Will try to create a sample one. - Meena Ganesan
That would be great and extremely helpful :) - Marcin Grzejszczak
What I figured was, when I introduce custom exception handling using @ControllerAdvice class extending ResponseEntityExceptionHandler, manually adding an error tag to the tracer in the handler does not report errors to Zipkin. - Meena Ganesan
Ok and the span is not null? That might mean that the order of execution has changed somehow and your tags are added AFTER they have already got reported to Zipkin. Can you please try with latest snapshots to see if the problem is still present? - Marcin Grzejszczak

1 Answers

1
votes

The issue got fixed - https://github.com/spring-cloud/spring-cloud-sleuth/issues/585 . In the upcoming releases 1.1.5 and 1.2.1 it should work