@Override public final void consume(final Span span) { if (numInflights.incrementAndGet() <= maxInflights) { ListenableFuture<Span> future = executorService.submit(() -> { doConsume(span); return span; }); Futures.addCallback(future, new FutureCallback<Span>() { @Override public void onSuccess(Span result) { numInflights.decrementAndGet(); } @Override public void onFailure(Throwable error) { log.trace("Failed to notify observer", error); numInflights.decrementAndGet(); } }); } else { log.trace("Failed to notify span observer since the maximum number of allowed concurrent observations was " + "exceeded", SafeArg.of("maxInflights", maxInflights)); numInflights.decrementAndGet(); } } }
@Override public final void consume(final Span span) { if (numInflights.incrementAndGet() <= maxInflights) { ListenableFuture<Span> future = executorService.submit(() -> { doConsume(span); return span; }); Futures.addCallback(future, new FutureCallback<Span>() { @Override public void onSuccess(Span result) { numInflights.decrementAndGet(); } @Override public void onFailure(Throwable error) { log.trace("Failed to notify observer", error); numInflights.decrementAndGet(); } }); } else { log.trace("Failed to notify span observer since the maximum number of allowed concurrent observations was " + "exceeded", SafeArg.of("maxInflights", maxInflights)); numInflights.decrementAndGet(); } } }