Skip to content

Commit 6c9220c

Browse files
committed
log: TimerMap keys when cardinality >10k
1 parent 5292b0a commit 6c9220c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

evcache-core/src/main/java/net/spy/memcached/EVCacheMemcachedClient.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public class EVCacheMemcachedClient extends MemcachedClient {
7878
private final EVCacheClient client;
7979
private final Map<String, Timer> timerMap = new ConcurrentHashMap<String, Timer>();
8080
private final Map<String, DistributionSummary> distributionSummaryMap = new ConcurrentHashMap<String, DistributionSummary>();
81+
private volatile boolean timerMapKeysLogged = false;
8182

8283
private Property<Long> mutateOperationTimeout;
8384
private final ConnectionFactory connectionFactory;
@@ -603,6 +604,21 @@ private Timer getTimer(String operation, String operationType, OperationStatus s
603604

604605
timer = EVCacheMetricsFactory.getInstance().getPercentileTimer(EVCacheMetricsFactory.IPC_CALL, tagList, Duration.ofMillis(maxDuration));
605606
timerMap.put(name, timer);
607+
608+
// Log timer map keys once if size exceeds threshold
609+
int mapSize = timerMap.size();
610+
if (mapSize > 10000 && !timerMapKeysLogged) {
611+
synchronized (this) {
612+
if (!timerMapKeysLogged) {
613+
timerMapKeysLogged = true;
614+
log.error("TimerMap size exceeded 10,000 entries. Current size: {}. Keys in map:", mapSize);
615+
for (String key : timerMap.keySet()) {
616+
log.error(" TimerMap key: {}", key);
617+
}
618+
}
619+
}
620+
}
621+
606622
return timer;
607623
}
608624

0 commit comments

Comments
 (0)