try {
// increment request counter
requestCounter.increment();
// invoke service through Hystrix
HystrixCommand<String> getCommand = new GetLogsCommand(key);
Future<String> future = getCommand.queue();
String responseString = future.get();
// increment the fallback counter if the response came from a
// fallback
// TODO: this isn't needed as the hystrix framework exports its own
// metrics on a per-command basis.
// this is here for demo purposes.
if (getCommand.isResponseFromFallback()) {
fallbackCounter.increment();
}
// increment the timeout counter if the response timed out and
// triggered fallback
// TODO: this isn't needed as the hystrix framework exports its own
// metrics on a per-command basis.
// this is here for demo purposes.
if (getCommand.isResponseTimedOut()) {
timeoutCounter.increment();
}
// return response
return Response.ok(responseString).build();