Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mica
mica
提交
fd663736
mica
项目概览
mica
/
mica
通知
10
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
mica
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fd663736
编写于
5月 10, 2021
作者:
如梦技术
🐛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
mica-jetcache 完成 metrics #37 #I3PX2K
上级
816ed30b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
2 deletion
+53
-2
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/metrics/JetCacheMonitorManager.java
...dreamlu/mica/jetcache/metrics/JetCacheMonitorManager.java
+53
-2
未找到文件。
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/metrics/JetCacheMonitorManager.java
浏览文件 @
fd663736
...
...
@@ -22,6 +22,8 @@ import com.alicp.jetcache.MultiLevelCache;
import
com.alicp.jetcache.anno.support.CacheMonitorManager
;
import
com.alicp.jetcache.support.DefaultCacheMonitor
;
import
com.alicp.jetcache.support.DefaultMetricsManager
;
import
io.micrometer.core.instrument.FunctionCounter
;
import
io.micrometer.core.instrument.Gauge
;
import
io.micrometer.core.instrument.MeterRegistry
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.InitializingBean
;
...
...
@@ -34,6 +36,22 @@ import org.springframework.lang.Nullable;
*/
@SuppressWarnings
(
"unchecked"
)
public
class
JetCacheMonitorManager
implements
CacheMonitorManager
,
InitializingBean
,
DisposableBean
{
/**
* Prefix used for all jetcache metric names.
*/
public
static
final
String
JETCACHE_METRIC_NAME_PREFIX
=
"jetcache"
;
/**
* metrics
*/
private
static
final
String
METRIC_NAME_JET_CACHE_CACHE_QPS
=
JETCACHE_METRIC_NAME_PREFIX
+
".qps"
;
private
static
final
String
METRIC_NAME_JET_CACHE_CACHE_RATE
=
JETCACHE_METRIC_NAME_PREFIX
+
".rate"
;
private
static
final
String
METRIC_NAME_JET_CACHE_CACHE_GET
=
JETCACHE_METRIC_NAME_PREFIX
+
".get"
;
private
static
final
String
METRIC_NAME_JET_CACHE_CACHE_HIT
=
JETCACHE_METRIC_NAME_PREFIX
+
".hit"
;
private
static
final
String
METRIC_NAME_JET_CACHE_CACHE_FAIL
=
JETCACHE_METRIC_NAME_PREFIX
+
".fail"
;
private
static
final
String
METRIC_NAME_JET_CACHE_CACHE_EXPIRE
=
JETCACHE_METRIC_NAME_PREFIX
+
".expire"
;
private
static
final
String
METRIC_NAME_JET_CACHE_CACHE_AVG_LOAD_TIME
=
JETCACHE_METRIC_NAME_PREFIX
+
".avg.load.time"
;
private
static
final
String
METRIC_NAME_JET_CACHE_CACHE_MAX_LOAD_TIME
=
JETCACHE_METRIC_NAME_PREFIX
+
".max.load.time"
;
@Nullable
private
final
DefaultMetricsManager
defaultMetricsManager
;
private
final
MeterRegistry
meterRegistry
;
...
...
@@ -91,8 +109,41 @@ public class JetCacheMonitorManager implements CacheMonitorManager, Initializing
private
static
void
registerMeters
(
MeterRegistry
meterRegistry
,
String
cacheName
,
DefaultCacheMonitor
remoteMonitor
)
{
DefaultCacheMonitor
cacheMonitor
)
{
// "qps", "rate", "get", "hit", "fail", "expire"
Gauge
.
builder
(
METRIC_NAME_JET_CACHE_CACHE_QPS
,
cacheMonitor
,
(
monitor
)
->
monitor
.
getCacheStat
().
qps
())
.
description
(
"JetCache qps"
)
.
tag
(
"name"
,
cacheName
)
.
register
(
meterRegistry
);
Gauge
.
builder
(
METRIC_NAME_JET_CACHE_CACHE_RATE
,
cacheMonitor
,
(
monitor
)
->
monitor
.
getCacheStat
().
hitRate
())
.
description
(
"JetCache rate"
)
.
tag
(
"name"
,
cacheName
)
.
register
(
meterRegistry
);
FunctionCounter
.
builder
(
METRIC_NAME_JET_CACHE_CACHE_GET
,
cacheMonitor
,
(
monitor
)
->
monitor
.
getCacheStat
().
getGetCount
())
.
description
(
"JetCache get"
)
.
tag
(
"name"
,
cacheName
)
.
register
(
meterRegistry
);
FunctionCounter
.
builder
(
METRIC_NAME_JET_CACHE_CACHE_HIT
,
cacheMonitor
,
(
monitor
)
->
monitor
.
getCacheStat
().
getGetHitCount
())
.
description
(
"JetCache hit"
)
.
tag
(
"name"
,
cacheName
)
.
register
(
meterRegistry
);
FunctionCounter
.
builder
(
METRIC_NAME_JET_CACHE_CACHE_FAIL
,
cacheMonitor
,
(
monitor
)
->
monitor
.
getCacheStat
().
getGetFailCount
())
.
description
(
"JetCache fail"
)
.
tag
(
"name"
,
cacheName
)
.
register
(
meterRegistry
);
FunctionCounter
.
builder
(
METRIC_NAME_JET_CACHE_CACHE_EXPIRE
,
cacheMonitor
,
(
monitor
)
->
monitor
.
getCacheStat
().
getGetExpireCount
())
.
description
(
"JetCache expire"
)
.
tag
(
"name"
,
cacheName
)
.
register
(
meterRegistry
);
// "avgLoadTime", "maxLoadTime"
Gauge
.
builder
(
METRIC_NAME_JET_CACHE_CACHE_AVG_LOAD_TIME
,
cacheMonitor
,
(
monitor
)
->
monitor
.
getCacheStat
().
avgLoadTime
())
.
description
(
"JetCache avg load time"
)
.
tag
(
"name"
,
cacheName
)
.
register
(
meterRegistry
);
Gauge
.
builder
(
METRIC_NAME_JET_CACHE_CACHE_MAX_LOAD_TIME
,
cacheMonitor
,
(
monitor
)
->
monitor
.
getCacheStat
().
getMaxLoadTime
())
.
description
(
"JetCache max load time"
)
.
tag
(
"name"
,
cacheName
)
.
register
(
meterRegistry
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录