diff --git a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/AtlasRegistry.java b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/AtlasRegistry.java index f957bab3b..f46c84208 100644 --- a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/AtlasRegistry.java +++ b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/AtlasRegistry.java @@ -253,15 +253,13 @@ private void timePublishTask(String id, Runnable task) { } private void timePublishTask(String id, String lockName, Runnable task) { - publishTaskTimer(id).recordRunnable(() -> { - Lock lock = publishTaskLocks.computeIfAbsent(lockName, n -> new ReentrantLock()); - lock.lock(); - try { - task.run(); - } finally { - lock.unlock(); - } - }); + Lock lock = publishTaskLocks.computeIfAbsent(lockName, n -> new ReentrantLock()); + lock.lock(); + try { + publishTaskTimer(id).recordRunnable(task); + } finally { + lock.unlock(); + } } void sendToAtlas() {