Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
61258bf8
R
Rocketmq
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
61258bf8
编写于
2月 18, 2019
作者:
D
duhenglucky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add StatsItem print logic
上级
9297d560
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
33 deletion
+25
-33
common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
...n/java/org/apache/rocketmq/common/stats/StatsItemSet.java
+3
-6
snode/src/main/java/org/apache/rocketmq/snode/service/impl/MetricsServiceImpl.java
...pache/rocketmq/snode/service/impl/MetricsServiceImpl.java
+22
-27
未找到文件。
common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
浏览文件 @
61258bf8
...
...
@@ -162,14 +162,11 @@ public class StatsItemSet {
StatsItem
statsItem
=
this
.
statsItemTable
.
get
(
statsKey
);
if
(
null
==
statsItem
)
{
statsItem
=
new
StatsItem
(
this
.
statsName
,
statsKey
,
this
.
scheduledExecutorService
,
this
.
log
);
StatsItem
prev
=
this
.
statsItemTable
.
put
(
statsKey
,
statsItem
);
if
(
null
==
prev
)
{
// statsItem.init();
StatsItem
prev
=
this
.
statsItemTable
.
putIfAbsent
(
statsKey
,
statsItem
);
if
(
null
!=
prev
)
{
statsItem
=
prev
;
}
}
return
statsItem
;
}
...
...
snode/src/main/java/org/apache/rocketmq/snode/service/impl/MetricsServiceImpl.java
浏览文件 @
61258bf8
...
...
@@ -16,38 +16,38 @@
*/
package
org.apache.rocketmq.snode.service.impl
;
import
io.prometheus.client.CollectorRegistry
;
import
io.prometheus.client.Counter
;
import
io.prometheus.client.Summary
;
import
io.prometheus.client.exporter.HTTPServer
;
import
io.prometheus.client.hotspot.DefaultExports
;
import
java.util.LinkedList
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ThreadFactory
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.common.protocol.ResponseCode
;
import
org.apache.rocketmq.common.
utils.CallSnapsho
t
;
import
org.apache.rocketmq.common.
stats.StatsItemSe
t
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.snode.exception.SnodeException
;
import
org.apache.rocketmq.snode.service.MetricsService
;
public
class
MetricsServiceImpl
implements
MetricsService
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
SNODE
_LOGGER_NAME
);
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
ROCKETMQ_STATS
_LOGGER_NAME
);
private
HTTPServer
server
;
public
MetricsServiceImpl
()
{
}
private
final
Map
<
Integer
,
LinkedList
<
CallSnapshot
>>
requestTimesList
=
new
ConcurrentHashMap
<>()
;
private
HTTPServer
server
;
private
final
Map
<
String
,
LinkedList
<
CallSnapshot
>>
topicSizeList
=
new
ConcurrentHashMap
<>();
private
final
ScheduledExecutorService
scheduledExecutorService
=
Executors
.
newSingleThreadScheduledExecutor
(
new
ThreadFactory
()
{
@Override
public
Thread
newThread
(
Runnable
r
)
{
return
new
Thread
(
r
,
"SNodeStatsScheduledThread"
);
}
});
// private Map<Integer, AtomicLong> requestTotalMap = new ConcurrentHashMap<>(512);
//
// private Map<Integer, AtomicLong> requestFailedTotalMap = new ConcurrentHashMap<>(512);
//
// private Map<String, AtomicLong> produceSizeTotal = new ConcurrentHashMap<>(512);
//
// private Map<String, AtomicLong> consumeSizeTotal = new ConcurrentHashMap<>(512);
StatsItemSet
statsItemSet
=
new
StatsItemSet
(
"SnodeStats"
,
scheduledExecutorService
,
log
);
private
final
Counter
requestTotal
=
Counter
.
build
().
name
(
"request_total"
).
help
(
"request total count"
).
labelNames
(
"requestCode"
).
register
();
...
...
@@ -66,30 +66,25 @@ public class MetricsServiceImpl implements MetricsService {
.
labelNames
(
"topic"
)
.
name
(
"sent_topic_size_bytes"
).
help
(
"Request size in bytes."
).
register
();
// public Double getLabelsValue(String labelValue) {
// return CollectorRegistry.defaultRegistry.getSampleValue("request_total", new String[] {"requestCode"}, new String[] {labelValue});
// }
private
AtomicLong
getValue
(
ConcurrentHashMap
map
,
Integer
key
)
{
AtomicLong
value
=
(
AtomicLong
)
map
.
get
(
key
);
if
(
value
==
null
)
{
value
=
(
AtomicLong
)
map
.
putIfAbsent
(
key
,
new
AtomicLong
(
0
));
}
return
value
;
public
Double
getLabelsValue
(
String
labelValue
)
{
return
CollectorRegistry
.
defaultRegistry
.
getSampleValue
(
"request_total"
,
new
String
[]
{
"requestCode"
},
new
String
[]
{
labelValue
});
}
@Override
synchronized
public
void
incRequestCount
(
int
requestCode
,
boolean
success
)
{
if
(!
success
)
{
this
.
requestFailedTotal
.
labels
(
requestCode
+
""
).
inc
();
this
.
statsItemSet
.
addValue
(
"TotalFailed@"
+
requestCode
,
1
,
1
);
}
else
{
this
.
requestTotal
.
labels
(
requestCode
+
""
).
inc
();
this
.
statsItemSet
.
addValue
(
"Total@"
+
requestCode
,
1
,
1
);
}
}
@Override
synchronized
public
void
recordRequestSize
(
String
topic
,
double
size
)
{
synchronized
public
void
recordRequestSize
(
String
topic
,
double
size
)
{
this
.
receivedBytes
.
labels
(
topic
).
observe
(
size
);
this
.
statsItemSet
.
addValue
(
"TotalSize@"
+
topic
,
new
Double
(
size
).
intValue
(),
1
);
}
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录