diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java index 662deaed13c91..cf6a76e32fbd7 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java @@ -100,7 +100,7 @@ public ExecutorListener(int uriStatDataLimitSize, int collectInterval) { this.clock = Clock.tick(collectInterval); this.snapshotQueue = new ConcurrentLinkedQueue<>(); - this.snapshotManager = new Snapshot<>(value -> new AgentUriStatData(value, uriStatDataLimitSize)); + this.snapshotManager = new Snapshot<>(value -> new AgentUriStatData(value, uriStatDataLimitSize), AgentUriStatData::getBaseTimestamp); } @Override @@ -138,7 +138,7 @@ public void executePollTimeout() { private boolean checkAndFlushOldData(long currentBaseTimestamp) { - final AgentUriStatData snapshot = snapshotManager.takeSnapshot(currentBaseTimestamp, AgentUriStatData::getBaseTimestamp); + final AgentUriStatData snapshot = snapshotManager.takeSnapshot(currentBaseTimestamp); if (snapshot != null) { addCompletedData(snapshot); return true; diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/Snapshot.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/Snapshot.java index 16a20a866bd15..da59c31abf4f8 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/Snapshot.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/Snapshot.java @@ -11,12 +11,14 @@ public class Snapshot { private T currentImage; private final LongFunction instanceFactory; + private final ToLongFunction currentImageTimestamp; - public Snapshot(LongFunction instanceFactory) { + public Snapshot(LongFunction instanceFactory, ToLongFunction currentImageTimestamp) { this.instanceFactory = Objects.requireNonNull(instanceFactory, "instanceFactory"); + this.currentImageTimestamp = Objects.requireNonNull(currentImageTimestamp, "currentImageTimestamp"); } - public T takeSnapshot(long currentBaseTimestamp, ToLongFunction currentImageTimestamp) { + public T takeSnapshot(long currentBaseTimestamp) { if (currentImage == null) { return null; }