Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
a160a6e4
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a160a6e4
编写于
5月 24, 2014
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the metric analyzer config problem
上级
ee22fd00
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
57 deletion
+27
-57
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
...java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
+7
-33
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/ProductLineConfigManager.java
...ianping/cat/consumer/metric/ProductLineConfigManager.java
+6
-4
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
...ain/java/com/dianping/cat/system/page/config/Handler.java
+11
-19
cat-home/src/main/webapp/jsp/system/metric/metricConfigs.jsp
cat-home/src/main/webapp/jsp/system/metric/metricConfigs.jsp
+3
-1
未找到文件。
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/MetricAnalyzer.java
浏览文件 @
a160a6e4
...
...
@@ -12,7 +12,6 @@ import org.unidal.lookup.util.StringUtils;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.analysis.AbstractMessageAnalyzer
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.advanced.dal.BusinessReport
;
...
...
@@ -53,6 +52,8 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
// key is project line,such as tuangou
private
Map
<
String
,
MetricReport
>
m_reports
=
new
HashMap
<
String
,
MetricReport
>();
private
static
final
String
METRIC
=
"metric"
;
@Override
public
void
doCheckpoint
(
boolean
atEnd
)
{
storeReports
(
atEnd
);
...
...
@@ -147,9 +148,6 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
Message
message
=
tree
.
getMessage
();
if
(
message
instanceof
Transaction
)
{
processMetricOnTransaction
(
product
,
report
,
(
Transaction
)
message
,
tree
);
}
if
(
message
instanceof
Transaction
)
{
processTransaction
(
product
,
report
,
tree
,
(
Transaction
)
message
);
}
else
if
(
message
instanceof
Metric
)
{
...
...
@@ -159,7 +157,7 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
private
int
processMetric
(
String
group
,
MetricReport
report
,
MessageTree
tree
,
Metric
metric
)
{
String
type
=
metric
.
getType
();
String
n
ame
=
metric
.
getName
();
String
metricN
ame
=
metric
.
getName
();
String
domain
=
tree
.
getDomain
();
String
data
=
(
String
)
metric
.
getData
();
String
status
=
metric
.
getStatus
();
...
...
@@ -171,41 +169,17 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
if
(
config
!=
null
)
{
long
current
=
metric
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
String
key
=
m_configManager
.
buildMetricKey
(
domain
,
"Metric"
,
n
ame
);
String
key
=
m_configManager
.
buildMetricKey
(
domain
,
METRIC
,
metricN
ame
);
MetricItem
metricItem
=
report
.
findOrCreateMetricItem
(
key
);
metricItem
.
addDomain
(
domain
).
setType
(
status
);
updateMetric
(
metricItem
,
min
,
config
.
getCount
(),
config
.
getValue
());
config
.
setTitle
(
name
);
m_configManager
.
insertIfNotExist
(
domain
,
"Metric"
,
name
,
config
);
}
return
0
;
}
private
void
processMetricOnTransaction
(
String
product
,
MetricReport
report
,
Transaction
transaction
,
MessageTree
tree
)
{
String
type
=
transaction
.
getType
();
config
.
setTitle
(
metricName
);
if
(
type
.
equals
(
"Service"
))
{
type
=
"PigeonService"
;
}
if
(
"URL"
.
equals
(
type
)
||
"PigeonService"
.
equals
(
type
))
{
String
domain
=
tree
.
getDomain
();
String
name
=
transaction
.
getName
();
String
key
=
m_configManager
.
buildMetricKey
(
domain
,
type
,
name
);
MetricItemConfig
config
=
m_configManager
.
queryMetricItemConfig
(
key
);
if
(
config
!=
null
)
{
long
current
=
transaction
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
double
sum
=
transaction
.
getDurationInMicros
();
MetricItem
metricItem
=
report
.
findOrCreateMetricItem
(
key
);
metricItem
.
addDomain
(
domain
).
setType
(
"C"
);
updateMetric
(
metricItem
,
min
,
1
,
sum
);
}
m_configManager
.
insertIfNotExist
(
domain
,
METRIC
,
metricName
,
config
);
}
return
0
;
}
private
int
processTransaction
(
String
group
,
MetricReport
report
,
MessageTree
tree
,
Transaction
t
)
{
...
...
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/metric/ProductLineConfigManager.java
浏览文件 @
a160a6e4
...
...
@@ -58,7 +58,9 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
public
static
final
String
SYSTEM_MONITOR
=
"系统监控"
;
public
static
final
String
NETWORK_MONITOR_PREFIX
=
"network-"
;
public
static
final
String
NETWORK_SWITCH_PREFIX
=
"switch-"
;
public
static
final
String
NETWORK_F5_PREFIX
=
"f5-"
;
public
static
final
String
SYSTEM_MONITOR_PREFIX
=
"system-"
;
...
...
@@ -132,11 +134,12 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
if
(
"broker-service"
.
equals
(
domain
))
{
userMonitor
=
true
;
}
else
if
(
line
.
startsWith
(
NETWORK_
MONITOR
_PREFIX
))
{
}
else
if
(
line
.
startsWith
(
NETWORK_
SWITCH_PREFIX
)
||
line
.
startsWith
(
NETWORK_F5
_PREFIX
))
{
networkMonitor
=
true
;
}
else
if
(
line
.
startsWith
(
SYSTEM_MONITOR_PREFIX
))
{
systemMonitor
=
true
;
}
productLine
.
setNetworkDashboard
(
networkMonitor
);
productLine
.
setUserMonitorDashboard
(
userMonitor
);
productLine
.
setSystemMonitorDashboard
(
systemMonitor
);
...
...
@@ -168,9 +171,8 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
return
storeConfig
();
}
}
}
else
{
return
false
;
}
return
false
;
}
public
boolean
insertProductLine
(
ProductLine
line
,
String
[]
domains
)
{
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
浏览文件 @
a160a6e4
...
...
@@ -428,28 +428,20 @@ public class Handler implements PageHandler<Context> {
Set
<
String
>
exists
=
new
HashSet
<
String
>();
for
(
Entry
<
String
,
ProductLine
>
entry
:
productLines
.
entrySet
())
{
Set
<
String
>
domains
=
entry
.
getValue
().
getDomains
().
keySet
();
List
<
MetricItemConfig
>
configs
=
m_metricConfigManager
.
queryMetricItemConfigs
(
domains
);
for
(
MetricItemConfig
config
:
configs
)
{
exists
.
add
(
m_metricConfigManager
.
buildMetricKey
(
config
.
getDomain
(),
config
.
getType
(),
config
.
getMetricKey
()));
ProductLine
productLine
=
entry
.
getValue
();
if
(
productLine
.
isMetricDashboard
())
{
Set
<
String
>
domains
=
productLine
.
getDomains
().
keySet
();
List
<
MetricItemConfig
>
configs
=
m_metricConfigManager
.
queryMetricItemConfigs
(
domains
);
for
(
MetricItemConfig
config
:
configs
)
{
exists
.
add
(
m_metricConfigManager
.
buildMetricKey
(
config
.
getDomain
(),
config
.
getType
(),
config
.
getMetricKey
()));
}
metricConfigs
.
put
(
productLine
,
configs
);
}
metricConfigs
.
put
(
entry
.
getValue
(),
configs
);
}
Map
<
String
,
MetricItemConfig
>
allConfigs
=
m_metricConfigManager
.
getMetricConfig
().
getMetricItemConfigs
();
Set
<
String
>
keysClone
=
new
HashSet
<
String
>(
allConfigs
.
keySet
());
List
<
MetricItemConfig
>
otherConfigs
=
new
ArrayList
<
MetricItemConfig
>();
for
(
String
key
:
exists
)
{
keysClone
.
remove
(
key
);
}
for
(
String
str
:
keysClone
)
{
otherConfigs
.
add
(
allConfigs
.
get
(
str
));
}
ProductLine
otherProductLine
=
new
ProductLine
(
"Other"
).
setTitle
(
"Other"
);
metricConfigs
.
put
(
otherProductLine
,
otherConfigs
);
model
.
setProductMetricConfigs
(
metricConfigs
);
}
...
...
cat-home/src/main/webapp/jsp/system/metric/metricConfigs.jsp
浏览文件 @
a160a6e4
...
...
@@ -100,7 +100,9 @@
<th
width=
"8%"
><h5
class=
'text-center'
>
显示次数
</h5></th>
<th
width=
"8%"
><h5
class=
'text-center'
>
显示平均值
</h5></th>
<th
width=
"8%"
><h5
class=
'text-center'
>
显示总和
</h5></th>
<th
width=
"13%"
><h5
class=
'text-center'
>
操作
<a
class=
"btn update btn-primary btn-small"
href=
"?op=metricConfigAdd&metricKey=${config.metricKey}&domain=${config.domain}&productLineName=${key}"
>
新增
</a></h5></th>
<th
width=
"13%"
><h5
class=
'text-center'
>
操作
<%-- <a class="btn update btn-primary btn-small" href="?op=metricConfigAdd&metricKey=${config.metricKey}&domain=${config.domain}&productLineName=${key}">新增</a>
--%>
</h5></th>
</tr>
<c:forEach
var=
"config"
items=
"
${
value
}
"
>
<tr>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录