From a8295c7d80d7d2af9a4252dd23bc1c1537f6fd57 Mon Sep 17 00:00:00 2001 From: Brian Harrington Date: Thu, 14 Mar 2024 10:58:53 -0500 Subject: [PATCH] atlas: limit task timer to just the task Will look at the lock time separately. Helps to avoid confusion about how long the actual work of the task is taking. --- .../netflix/spectator/atlas/AtlasRegistry.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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() {