Repository: pinpoint-apm/pinpoint
Issue: Add time filtering when querying agents for Realtime data
Labels: enhancement

When querying for realtime data such as the active thread chart, servers that are no longer in use are of no interest. These servers are currently displayed as _NOT_FOUND_ and will continue to be displayed until the TTL value set in HBase.

It might be a good idea to set a reasonable time buffer (perhaps a week?) when querying for these agents so that servers that were down for longer than a week does not show up in the active thread chart and confuse everyone.


Issue comments:
Api change affects transaction list queries - reopening issue.

Reopening issue to add configuration option for the duration determining agent inactivity.


Pull request review comments:

Patch that resolved the issue:
diff --git a/web/src/main/java/com/navercorp/pinpoint/web/service/AgentServiceImpl.java b/web/src/main/java/com/navercorp/pinpoint/web/service/AgentServiceImpl.java
index 00053762d74e..0112e4e0b42c 100644
--- a/web/src/main/java/com/navercorp/pinpoint/web/service/AgentServiceImpl.java
+++ b/web/src/main/java/com/navercorp/pinpoint/web/service/AgentServiceImpl.java
@@ -48,6 +48,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -62,11 +63,10 @@ public class AgentServiceImpl implements AgentService {
 
     private static final long DEFAULT_FUTURE_TIMEOUT = 3000;
 
-    private static final long DEFAULT_TIME_DIFF_DAYS = 7;
-    private static final long DEFAULT_TIME_DIFF_MS = TimeUnit.MILLISECONDS.convert(DEFAULT_TIME_DIFF_DAYS, TimeUnit.DAYS);
-
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
+    private long timeDiffMs;
+
     @Autowired
     private AgentInfoService agentInfoService;
 
@@ -79,6 +79,11 @@ public class AgentServiceImpl implements AgentService {
     @Autowired
     private DeserializerFactory<HeaderTBaseDeserializer> commandDeserializerFactory;
 
+    @Value("#{pinpointWebProps['web.activethread.activeAgent.duration.days'] ?: 7}")
+    private void setTimeDiffMs(int durationDays) {
+        this.timeDiffMs = TimeUnit.MILLISECONDS.convert(durationDays, TimeUnit.DAYS);
+    }
+
     @Override
     public AgentInfo getAgentInfo(String applicationName, String agentId) {
         long currentTime = System.currentTimeMillis();
@@ -140,7 +145,7 @@ public AgentInfo getAgentInfo(String applicationName, String agentId, long start
 
     @Override
     public List<AgentInfo> getRecentAgentInfoList(String applicationName) {
-        return this.getRecentAgentInfoList(applicationName, DEFAULT_TIME_DIFF_MS);
+        return this.getRecentAgentInfoList(applicationName, this.timeDiffMs);
     }
 
     @Override
diff --git a/web/src/main/resources/pinpoint-web.properties b/web/src/main/resources/pinpoint-web.properties
index 29fc033e67ce..61153f362543 100644
--- a/web/src/main/resources/pinpoint-web.properties
+++ b/web/src/main/resources/pinpoint-web.properties
@@ -20,3 +20,5 @@ config.editUserInfo=true
 
 web.hbase.selectSpans.limit=500
 web.hbase.selectAllSpans.limit=500
+
+web.activethread.activeAgent.duration.days=7
\ No newline at end of file


Test patch: