I successfully configured spring-cloud
(via spring-cloud-starter-hystrix
) to wrap a call to a service.
This all works fine and looks like the following:
@Component
public class MyService {
@HystrixCommand(fallbackMethod = "fallback")
public void longRunning() {
// this could fail
}
public void fallback() {
// fallback code
}
}
My question now is, I would like to log some statistics about the execution error in longRunning()
Trying to access HystrixRequestLog.getCurrentRequest()
within the fallback method throws
java.lang.IllegalStateException: HystrixRequestContext.initializeContext() must be called at the beginning of each request before RequestVariable functionality can be used.
I am looking for a simple way to log the exception of longRunning
if the fallback is called.
testing with v1.0.0.RC2