Hi all,
I am experimenting with Hystrix and I was wondering what the best practices are around error logging in cases where a fallback value is provided.
For example, suppose that service A calls service B inside a HystrixCommand and I have overridden getFallback() for this command so that a reasonable default value is used in the failure case.
If service B goes down, I'd like to implement the following so that I can better understand the application's behavior when looking at the logs:
- If the circuit is currently closed, write an error log line in service A's logs which identifies the Exception that caused the failure (e.g. a ConnectException) and its stack trace.
- If the circuit is currently open, write an error log line in service A's logs when the command is invoked, ideally including the command name and stack trace.
- Write these log lines in the proper sequence, as opposed to writing all hystrix-related log data in a request context filter or similar at the end of a request.
- Share this behavior across the multiple HystrixCommand subclasses I create without duplicating the basic logging code.
The only solution I have so far is to create an abstract class descending from HystrixCommand which adds this functionality and returns a value provided by a new overrideable method, then make all my HystrixCommand classes descend from that new one.
From what I've seen in the docs and on github, this does not appear to be a common usage pattern. Given that error logging is such a common concern, I have the sense that I'm working against the grain here. I would love your thoughts on the cleanest approach or an alternative way of thinking about this.
Thanks in advance for your help and for this great project!
Jim