Skip to content

Commit dcc929d

Browse files
committed
Merge branch 'v1.3.3'
2 parents f2f777f + 3918a6f commit dcc929d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Diff for: camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/monitor/LoggingMonitorCallback.java

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.netease.nim.camellia.redis.proxy.monitor;
22

33
import com.netease.nim.camellia.redis.proxy.monitor.model.*;
4+
import com.netease.nim.camellia.redis.proxy.util.Utils;
45
import org.slf4j.Logger;
56
import org.slf4j.LoggerFactory;
67

@@ -177,6 +178,14 @@ public void callback(Stats stats) {
177178
kvRunToCompletionStats.getHit(), kvRunToCompletionStats.getNotHit(), kvRunToCompletionStats.getHitRate());
178179
}
179180

181+
logger.info("====kv.lru.cache.stats====");
182+
List<KvLRUCacheStats> kvLRUCacheStatsList = stats.getKvLRUCacheStatsList();
183+
for (KvLRUCacheStats kvLRUCacheStats : kvLRUCacheStatsList) {
184+
logger.info("namespace={},capacity={},keyCount={},currentSize={},targetSize={}",
185+
kvLRUCacheStats.getNamespace(), kvLRUCacheStats.getCapacity(),
186+
kvLRUCacheStats.getKeyCount(), Utils.humanReadableByteCountBin(kvLRUCacheStats.getCurrentSize()), Utils.humanReadableByteCountBin(kvLRUCacheStats.getTargetSize()));
187+
}
188+
180189
logger.info("<<<<<<<END<<<<<<<");
181190
} catch (Exception e) {
182191
logger.error(e.getMessage(), e);

Diff for: camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/monitor/PrometheusMetrics.java

+14
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,20 @@ public static String metrics() {
436436
kvRunToCompletionStats.getNamespace(), kvRunToCompletionStats.getCommand(), kvRunToCompletionStats.getHitRate()));
437437
}
438438

439+
List<KvLRUCacheStats> kvLRUCacheStatsList = stats.getKvLRUCacheStatsList();
440+
builder.append("# HELP kv_lru_cache Redis Proxy KV LRU Cache Stats\n");
441+
builder.append("# TYPE kv_lru_cache gauge\n");
442+
for (KvLRUCacheStats kvLRUCacheStats : kvLRUCacheStatsList) {
443+
builder.append(prefix).append(String.format("kv_lru_cache_stats{namespace=\"%s\", type=\"capacity\"} %d\n",
444+
kvLRUCacheStats.getNamespace(), kvLRUCacheStats.getCapacity()));
445+
builder.append(prefix).append(String.format("kv_lru_cache_stats{namespace=\"%s\", type=\"key_count\"} %d\n",
446+
kvLRUCacheStats.getNamespace(), kvLRUCacheStats.getKeyCount()));
447+
builder.append(prefix).append(String.format("kv_lru_cache_stats{namespace=\"%s\", type=\"current_size\"} %d\n",
448+
kvLRUCacheStats.getNamespace(), kvLRUCacheStats.getCurrentSize()));
449+
builder.append(prefix).append(String.format("kv_lru_cache_stats{namespace=\"%s\", type=\"target_size\"} %d\n",
450+
kvLRUCacheStats.getNamespace(), kvLRUCacheStats.getTargetSize()));
451+
}
452+
439453
return builder.toString();
440454
}
441455

0 commit comments

Comments
 (0)