Skip to content

Commit

Permalink
Merge pull request #1152 from elandau/improve_logging
Browse files Browse the repository at this point in the history
Improved logging
  • Loading branch information
qiangdavidliu committed Nov 12, 2018
2 parents 12712a9 + 65567e4 commit 44bf4ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
public class TimedSupervisorTask extends TimerTask {
private static final Logger logger = LoggerFactory.getLogger(TimedSupervisorTask.class);

private final Counter successCounter;
private final Counter timeoutCounter;
private final Counter rejectedCounter;
private final Counter throwableCounter;
Expand All @@ -48,6 +49,7 @@ public TimedSupervisorTask(String name, ScheduledExecutorService scheduler, Thre
this.maxDelay = timeoutMillis * expBackOffBound;

// Initialize the counters and register.
successCounter = Monitors.newCounter("success");
timeoutCounter = Monitors.newCounter("timeouts");
rejectedCounter = Monitors.newCounter("rejectedExecutions");
throwableCounter = Monitors.newCounter("throwables");
Expand All @@ -64,6 +66,7 @@ public void run() {
future.get(timeoutMillis, TimeUnit.MILLISECONDS); // block until done or timeout
delay.set(timeoutMillis);
threadPoolLevelGauge.set((long) executor.getActiveCount());
successCounter.increment();
} catch (TimeoutException e) {
logger.warn("task supervisor timed out", e);
timeoutCounter.increment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ public Object readFrom(Class serializableClass, Type type,
} catch (Throwable e) {
if (e instanceof Error) { // See issue: https://github.com/Netflix/eureka/issues/72 on why we catch Error here.
closeInputOnError(inputStream);
throw new WebApplicationException(createErrorReply(500, e, mediaType));
throw new WebApplicationException(e, createErrorReply(500, e, mediaType));
}
LOGGER.debug("Cannot parse request body", e);
throw new WebApplicationException(createErrorReply(400, "cannot parse request body", mediaType));
throw new WebApplicationException(e, createErrorReply(400, "cannot parse request body", mediaType));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ protected <R> EurekaHttpResponse<R> execute(RequestExecutor<R> requestExecutor)
TransportUtils.shutdown(delegateRef.getAndSet(currentEurekaClientRef.get()));
return response;
} catch (Exception e) {
logger.error("Request execution error", e);
logger.error("Request execution error. endpoint={}", serviceEndpoint, e);
TransportUtils.shutdown(currentEurekaClientRef.get());
throw e;
}
} else {
try {
return requestExecutor.execute(currentEurekaClient);
} catch (Exception e) {
logger.error("Request execution error", e);
logger.error("Request execution error. endpoint={}", serviceEndpoint, e);
delegateRef.compareAndSet(currentEurekaClient, null);
currentEurekaClient.shutdown();
throw e;
Expand Down

0 comments on commit 44bf4ca

Please sign in to comment.