diff --git a/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limiter/SimpleLimiter.java b/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limiter/SimpleLimiter.java index cd748bdd..1d916028 100644 --- a/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limiter/SimpleLimiter.java +++ b/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limiter/SimpleLimiter.java @@ -49,12 +49,16 @@ public SimpleLimiter(AbstractLimiter.Builder builder) { @Override public Optional acquire(ContextT context) { + Optional listener; if (!semaphore.tryAcquire()) { - return createRejectedListener(); + listener = createRejectedListener(); } - Listener listener = new Listener(createListener()); + else { + listener = Optional.of(new Listener(createListener())); + } + inflightDistribution.addSample(getInflight()); - return Optional.of(listener); + return listener; } @Override