1

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?

Helmar
  • 107
  • 2
  • 11
  • 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 May 04 '17 at 20:00
  • @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 May 04 '17 at 20:16
  • 1
    That would be great and extremely helpful :) – Marcin Grzejszczak May 04 '17 at 20:16
  • 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 May 04 '17 at 20:19
  • 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 May 04 '17 at 20:20
  • @MarcinGrzejszczak Here is a sample project I created - https://github.com/meena-ganesan/SleuthTest I can visualize errors in Zipkin only if: 1) ControllerAdvice is commented in com.test.exception.CustomExceptionHandler 2) the Spring Boot is updated to 1.4.3 & Slueth & Zipkin to 1.1.0 in build.gradle. – Meena Ganesan May 05 '17 at 01:03
  • I've filed an issue in Sleuth - https://github.com/spring-cloud/spring-cloud-sleuth/issues/585 and I'm on verge of fixing it (hopefully) – Marcin Grzejszczak May 05 '17 at 13:54
  • @MarcinGrzejszczak Thank you for the support. – Meena Ganesan May 08 '17 at 14:09
  • Sure - hopefully it's working fine ;) – Marcin Grzejszczak May 08 '17 at 14:10

1 Answers1

1

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

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32