Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
8270cfe7
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,发现更多精彩内容 >>
提交
8270cfe7
编写于
6月 21, 2013
作者:
Y
yong.you
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the metric config
上级
a4c443a8
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
541 addition
and
70 deletion
+541
-70
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
...va/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
+96
-17
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricConfigManager.java
...m/dianping/cat/consumer/advanced/MetricConfigManager.java
+57
-31
cat-consumer/src/main/java/com/dianping/cat/consumer/core/ProductLineConfigManager.java
.../dianping/cat/consumer/core/ProductLineConfigManager.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
...ain/java/com/dianping/cat/report/page/metric/Handler.java
+1
-1
cat-home/src/main/java/com/dianping/cat/system/page/config/Action.java
...main/java/com/dianping/cat/system/page/config/Action.java
+9
-1
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
...ain/java/com/dianping/cat/system/page/config/Handler.java
+64
-6
cat-home/src/main/java/com/dianping/cat/system/page/config/JspFile.java
...ain/java/com/dianping/cat/system/page/config/JspFile.java
+7
-1
cat-home/src/main/java/com/dianping/cat/system/page/config/JspViewer.java
...n/java/com/dianping/cat/system/page/config/JspViewer.java
+9
-0
cat-home/src/main/java/com/dianping/cat/system/page/config/Model.java
.../main/java/com/dianping/cat/system/page/config/Model.java
+21
-0
cat-home/src/main/java/com/dianping/cat/system/page/config/Payload.java
...ain/java/com/dianping/cat/system/page/config/Payload.java
+28
-5
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+3
-0
cat-home/src/main/resources/config/default-metric-config.xml
cat-home/src/main/resources/config/default-metric-config.xml
+5
-5
cat-home/src/main/webapp/jsp/system/configTree.jsp
cat-home/src/main/webapp/jsp/system/configTree.jsp
+1
-1
cat-home/src/main/webapp/jsp/system/metric/metricConfigAdd.jsp
...ome/src/main/webapp/jsp/system/metric/metricConfigAdd.jsp
+110
-0
cat-home/src/main/webapp/jsp/system/metric/metricConfigs.jsp
cat-home/src/main/webapp/jsp/system/metric/metricConfigs.jsp
+125
-0
cat-home/src/test/java/com/dianping/cat/demo/TestABTestBusinessMessage.java
...java/com/dianping/cat/demo/TestABTestBusinessMessage.java
+3
-0
未找到文件。
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
浏览文件 @
8270cfe7
...
...
@@ -10,7 +10,6 @@ import java.util.Set;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.tuple.Pair
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.CatConstants
;
...
...
@@ -124,11 +123,11 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
}
}
}
return
""
;
}
public
Map
<
String
,
String
>
parseABTests
(
String
str
)
{
// -1 is the all metric,design for default
Map
<
String
,
String
>
abtests
=
new
HashMap
<
String
,
String
>();
abtests
.
put
(
"-1"
,
""
);
...
...
@@ -168,44 +167,56 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
String
domain
=
tree
.
getDomain
();
String
data
=
(
String
)
metric
.
getData
();
String
status
=
metric
.
getStatus
();
Pair
<
Integer
,
Double
>
value
=
parseValue
(
status
,
data
);
ConfigItem
config
=
parseValue
(
status
,
data
);
if
(
value
!=
null
)
{
if
(
config
!=
null
)
{
long
current
=
metric
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
MetricItem
metricItem
=
report
.
findOrCreateMetricItem
(
name
);
Map
<
String
,
String
>
abtests
=
parseABTests
(
type
);
metricItem
.
addDomain
(
domain
).
setType
(
status
);
updateMetric
(
metricItem
,
abtests
,
min
,
value
.
getKey
(),
value
.
getValue
());
updateMetric
(
metricItem
,
abtests
,
min
,
config
.
getCount
(),
config
.
getValue
());
config
.
setTitle
(
name
);
m_configManager
.
insertIfNotExist
(
domain
,
"Metric"
,
name
,
config
);
}
return
0
;
}
private
Pair
<
Integer
,
Double
>
parseValue
(
String
status
,
String
data
)
{
Pair
<
Integer
,
Double
>
value
=
new
Pair
<
Integer
,
Double
>
();
private
ConfigItem
parseValue
(
String
status
,
String
data
)
{
ConfigItem
config
=
new
ConfigItem
();
if
(
"C"
.
equals
(
status
))
{
int
count
=
Integer
.
parseInt
(
data
);
value
.
setKey
(
count
);
value
.
setValue
((
double
)
count
);
config
.
setCount
(
count
);
config
.
setValue
((
double
)
count
);
config
.
setShowCount
(
true
);
}
else
if
(
"T"
.
equals
(
status
))
{
double
duration
=
Double
.
parseDouble
(
data
);
value
.
setKey
(
1
);
value
.
setValue
(
duration
);
config
.
setCount
(
1
);
config
.
setValue
(
duration
);
config
.
setShowAvg
(
true
);
}
else
if
(
"S"
.
equals
(
status
))
{
double
sum
=
Double
.
parseDouble
(
data
);
value
.
setKey
(
1
);
value
.
setValue
(
sum
);
config
.
setCount
(
1
);
config
.
setValue
(
sum
);
config
.
setShowSum
(
true
);
}
else
if
(
"S,C"
.
equals
(
status
))
{
String
[]
datas
=
data
.
split
(
","
);
value
.
setKey
(
Integer
.
parseInt
(
datas
[
0
]));
value
.
setValue
(
Double
.
parseDouble
(
datas
[
1
]));
config
.
setCount
(
Integer
.
parseInt
(
datas
[
0
]));
config
.
setValue
(
Double
.
parseDouble
(
datas
[
1
]));
config
.
setShowCount
(
true
);
config
.
setShowSum
(
true
);
}
else
{
return
null
;
}
return
value
;
return
config
;
}
private
int
processTransaction
(
String
group
,
MetricReport
report
,
MessageTree
tree
,
Transaction
t
)
{
...
...
@@ -229,7 +240,8 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
if
(
CatConstants
.
TYPE_URL
.
equals
(
type
))
{
String
name
=
transaction
.
getName
();
String
domain
=
tree
.
getDomain
();
MetricItemConfig
config
=
m_configManager
.
queryMetricItemConfig
(
domain
+
":"
+
name
);
String
key
=
m_configManager
.
buildMetricKey
(
domain
,
"URL"
,
name
);
MetricItemConfig
config
=
m_configManager
.
queryMetricItemConfig
(
key
);
if
(
config
!=
null
)
{
long
current
=
transaction
.
getTimestamp
()
/
1000
/
60
;
...
...
@@ -315,4 +327,71 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
point
.
setAvg
(
point
.
getSum
()
/
point
.
getCount
());
}
}
public
static
class
ConfigItem
{
private
int
m_count
;
private
double
m_value
;
private
boolean
m_showCount
=
false
;
private
boolean
m_showAvg
=
false
;
private
boolean
m_showSum
=
false
;
private
String
m_title
;
public
String
getTitle
()
{
return
m_title
;
}
public
void
setTitle
(
String
title
)
{
m_title
=
title
;
}
public
int
getCount
()
{
return
m_count
;
}
public
ConfigItem
setCount
(
int
count
)
{
m_count
=
count
;
return
this
;
}
public
double
getValue
()
{
return
m_value
;
}
public
ConfigItem
setValue
(
double
value
)
{
m_value
=
value
;
return
this
;
}
public
boolean
isShowCount
()
{
return
m_showCount
;
}
public
ConfigItem
setShowCount
(
boolean
showCount
)
{
m_showCount
=
showCount
;
return
this
;
}
public
boolean
isShowAvg
()
{
return
m_showAvg
;
}
public
ConfigItem
setShowAvg
(
boolean
showAvg
)
{
m_showAvg
=
showAvg
;
return
this
;
}
public
boolean
isShowSum
()
{
return
m_showSum
;
}
public
ConfigItem
setShowSum
(
boolean
showSum
)
{
m_showSum
=
showSum
;
return
this
;
}
}
}
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricConfigManager.java
浏览文件 @
8270cfe7
...
...
@@ -22,6 +22,7 @@ import com.dianping.cat.Cat;
import
com.dianping.cat.advanced.metric.config.entity.MetricConfig
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.advanced.metric.config.transform.DefaultSaxParser
;
import
com.dianping.cat.consumer.advanced.MetricAnalyzer.ConfigItem
;
import
com.dianping.cat.consumer.core.config.Config
;
import
com.dianping.cat.consumer.core.config.ConfigDao
;
import
com.dianping.cat.consumer.core.config.ConfigEntity
;
...
...
@@ -41,38 +42,12 @@ public class MetricConfigManager implements Initializable, LogEnabled {
private
static
final
String
CONFIG_NAME
=
"metricConfig"
;
public
MetricConfig
getMetricConfig
()
{
synchronized
(
m_metricConfig
)
{
return
m_metricConfig
;
}
}
public
boolean
insertMetricItemConfig
(
MetricItemConfig
config
){
getMetricConfig
().
addMetricItemConfig
(
config
);
return
storeConfig
();
}
public
MetricItemConfig
queryMetricItemConfig
(
String
id
)
{
return
getMetricConfig
().
findMetricItemConfig
(
id
);
public
String
buildMetricKey
(
String
domain
,
String
type
,
String
metricKey
)
{
return
domain
+
":"
+
type
+
":"
+
metricKey
;
}
public
List
<
MetricItemConfig
>
queryMetricItemConfig
(
Set
<
String
>
domains
)
{
List
<
MetricItemConfig
>
configs
=
new
ArrayList
<
MetricItemConfig
>();
Map
<
String
,
MetricItemConfig
>
metricConfig
=
getMetricConfig
().
getMetricItemConfigs
();
for
(
Entry
<
String
,
MetricItemConfig
>
entry
:
metricConfig
.
entrySet
())
{
MetricItemConfig
item
=
entry
.
getValue
();
if
(
domains
.
contains
(
item
.
getDomain
()))
{
configs
.
add
(
item
);
}
}
return
configs
;
}
public
boolean
deleteDomainConfig
(
String
domain
)
{
getMetricConfig
().
removeMetricItemConfig
(
domain
);
public
boolean
deleteDomainConfig
(
String
key
)
{
getMetricConfig
().
removeMetricItemConfig
(
key
);
return
storeConfig
();
}
...
...
@@ -81,6 +56,12 @@ public class MetricConfigManager implements Initializable, LogEnabled {
m_logger
=
logger
;
}
public
MetricConfig
getMetricConfig
()
{
synchronized
(
m_metricConfig
)
{
return
m_metricConfig
;
}
}
@Override
public
void
initialize
()
throws
InitializationException
{
try
{
...
...
@@ -109,11 +90,56 @@ public class MetricConfigManager implements Initializable, LogEnabled {
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
if
(
getMetricConfig
()
==
null
)
{
if
(
m_metricConfig
==
null
)
{
m_metricConfig
=
new
MetricConfig
();
}
}
public
boolean
insertIfNotExist
(
String
domain
,
String
type
,
String
metricKey
,
ConfigItem
item
)
{
String
key
=
buildMetricKey
(
domain
,
type
,
metricKey
);
MetricItemConfig
config
=
m_metricConfig
.
findMetricItemConfig
(
key
);
if
(
config
!=
null
)
{
return
true
;
}
else
{
config
=
new
MetricItemConfig
();
config
.
setDomain
(
domain
);
config
.
setType
(
type
);
config
.
setMetricKey
(
metricKey
);
config
.
setId
(
key
);
config
.
setTitle
(
item
.
getTitle
());
config
.
setShowAvg
(
item
.
isShowAvg
());
config
.
setShowCount
(
item
.
isShowCount
());
config
.
setShowSum
(
item
.
isShowSum
());
return
insertMetricItemConfig
(
config
);
}
}
public
boolean
insertMetricItemConfig
(
MetricItemConfig
config
)
{
getMetricConfig
().
addMetricItemConfig
(
config
);
return
storeConfig
();
}
public
MetricItemConfig
queryMetricItemConfig
(
String
id
)
{
return
getMetricConfig
().
findMetricItemConfig
(
id
);
}
public
List
<
MetricItemConfig
>
queryMetricItemConfigs
(
Set
<
String
>
domains
)
{
List
<
MetricItemConfig
>
configs
=
new
ArrayList
<
MetricItemConfig
>();
Map
<
String
,
MetricItemConfig
>
metricConfig
=
getMetricConfig
().
getMetricItemConfigs
();
for
(
Entry
<
String
,
MetricItemConfig
>
entry
:
metricConfig
.
entrySet
())
{
MetricItemConfig
item
=
entry
.
getValue
();
if
(
domains
.
contains
(
item
.
getDomain
()))
{
configs
.
add
(
item
);
}
}
return
configs
;
}
private
void
refreshMetricConfig
()
throws
DalException
,
SAXException
,
IOException
{
Config
config
=
m_configDao
.
findByName
(
CONFIG_NAME
,
ConfigEntity
.
READSET_FULL
);
long
modifyTime
=
config
.
getModifyDate
().
getTime
();
...
...
cat-consumer/src/main/java/com/dianping/cat/consumer/core/ProductLineConfigManager.java
浏览文件 @
8270cfe7
...
...
@@ -126,7 +126,7 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
}
return
domains
;
}
public
Map
<
String
,
ProductLine
>
queryProductLines
()
{
Map
<
String
,
ProductLine
>
productLines
=
new
TreeMap
<
String
,
ProductLine
>();
...
...
@@ -137,7 +137,7 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
@Override
public
int
compare
(
Entry
<
String
,
ProductLine
>
o1
,
Entry
<
String
,
ProductLine
>
o2
)
{
return
(
int
)
(
o
2
.
getValue
().
getOrder
()
*
100
-
o1
.
getValue
().
getOrder
()
*
100
);
return
(
int
)
(
o
1
.
getValue
().
getOrder
()
*
100
-
o2
.
getValue
().
getOrder
()
*
100
);
}
});
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
浏览文件 @
8270cfe7
...
...
@@ -80,7 +80,7 @@ public class Handler implements PageHandler<Context> {
}
String
product
=
payload
.
getProduct
();
List
<
String
>
domains
=
m_productLineConfigManager
.
queryProductLineDomains
(
product
);
List
<
MetricItemConfig
>
domainSet
=
m_configManager
.
queryMetricItemConfig
(
new
HashSet
<
String
>(
domains
));
List
<
MetricItemConfig
>
domainSet
=
m_configManager
.
queryMetricItemConfig
s
(
new
HashSet
<
String
>(
domains
));
MetricDisplay
display
=
new
MetricDisplay
(
domainSet
,
test
,
startTime
);
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/Action.java
浏览文件 @
8270cfe7
...
...
@@ -37,7 +37,15 @@ public enum Action implements org.unidal.web.mvc.Action {
TOPOLOGY_GRAPH_PRODUCT_LINE_ADD_OR_UPDATE_SUBMIT
(
"topologyProductLineAddSubmit"
),
TOPOLOGY_GRAPH_PRODUCT_LINE_DELETE
(
"topologyProductLineDelete"
)
TOPOLOGY_GRAPH_PRODUCT_LINE_DELETE
(
"topologyProductLineDelete"
),
METRIC_CONFIG_LIST
(
"metricConfigList"
),
METRIC_CONFIG_ADD_OR_UPDATE
(
"metricConfigAdd"
),
METRIC_CONFIG_ADD_OR_UPDATE_SUBMIT
(
"metricConfigAddSumbit"
),
METRIC_CONFIG_DELETE
(
"metricConfigDelete"
)
;
private
String
m_name
;
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
浏览文件 @
8270cfe7
...
...
@@ -4,7 +4,11 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
javax.servlet.ServletException
;
...
...
@@ -18,6 +22,8 @@ import org.unidal.web.mvc.annotation.OutboundActionMeta;
import
org.unidal.web.mvc.annotation.PayloadMeta
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.consumer.advanced.MetricConfigManager
;
import
com.dianping.cat.consumer.aggreation.model.entity.AggregationRule
;
import
com.dianping.cat.consumer.company.model.entity.ProductLine
;
import
com.dianping.cat.consumer.core.ProductLineConfigManager
;
...
...
@@ -41,13 +47,16 @@ public class Handler implements PageHandler<Context> {
@Inject
private
TopologyGraphConfigManager
m_topologyConfigManager
;
@Inject
private
ProductLineConfigManager
m_productLineConfigManger
;
@Inject
private
AggregationConfigManager
m_aggreationConfigManager
;
@Inject
private
MetricConfigManager
m_metricConfigManager
;
@Inject
private
DomainNavManager
m_manager
;
...
...
@@ -154,8 +163,7 @@ public class Handler implements PageHandler<Context> {
model
.
setAggregationRules
(
m_aggreationConfigManager
.
queryAggrarationRules
());
break
;
case
AGGREGATION_UPDATE:
model
.
setAggregationRule
(
m_aggreationConfigManager
.
queryAggration
(
payload
.
getPattern
()));
model
.
setAggregationRule
(
m_aggreationConfigManager
.
queryAggration
(
payload
.
getPattern
()));
break
;
case
AGGREGATION_UPDATE_SUBMIT:
updateAggregationRule
(
payload
);
...
...
@@ -216,10 +224,60 @@ public class Handler implements PageHandler<Context> {
model
.
setOpState
(
graphProductLineConfigAddOrUpdateSubmit
(
payload
,
model
));
model
.
setProductLines
(
m_productLineConfigManger
.
queryProductLines
());
break
;
case
METRIC_CONFIG_ADD_OR_UPDATE:
metricConfigAdd
(
payload
,
model
);
model
.
setProjects
(
queryAllProjects
());
break
;
case
METRIC_CONFIG_ADD_OR_UPDATE_SUBMIT:
model
.
setOpState
(
metricConfigAddSubmit
(
payload
,
model
));
metricConfigList
(
payload
,
model
);
break
;
case
METRIC_CONFIG_LIST:
metricConfigList
(
payload
,
model
);
break
;
case
METRIC_CONFIG_DELETE:
model
.
setOpState
(
m_metricConfigManager
.
deleteDomainConfig
(
m_metricConfigManager
.
buildMetricKey
(
payload
.
getDomain
(),
payload
.
getType
(),
payload
.
getMetricKey
())));
metricConfigList
(
payload
,
model
);
break
;
}
m_jspViewer
.
view
(
ctx
,
model
);
}
private
void
metricConfigAdd
(
Payload
payload
,
Model
model
)
{
String
key
=
m_metricConfigManager
.
buildMetricKey
(
payload
.
getDomain
(),
payload
.
getType
(),
payload
.
getMetricKey
());
model
.
setMetricItemConfig
(
m_metricConfigManager
.
queryMetricItemConfig
(
key
));
}
private
boolean
metricConfigAddSubmit
(
Payload
payload
,
Model
model
)
{
MetricItemConfig
config
=
payload
.
getMetricItemConfig
();
String
domain
=
config
.
getDomain
();
String
type
=
config
.
getType
();
String
metricKey
=
config
.
getMetricKey
();
if
(!
StringUtil
.
isEmpty
(
domain
)&&!
StringUtil
.
isEmpty
(
type
)
&&
!
StringUtil
.
isEmpty
(
metricKey
))
{
config
.
setId
(
m_metricConfigManager
.
buildMetricKey
(
domain
,
type
,
metricKey
));
return
m_metricConfigManager
.
insertMetricItemConfig
(
config
);
}
else
{
return
false
;
}
}
private
void
metricConfigList
(
Payload
payload
,
Model
model
)
{
Map
<
String
,
ProductLine
>
productLins
=
m_productLineConfigManger
.
queryProductLines
();
Map
<
ProductLine
,
List
<
MetricItemConfig
>>
metricConfigs
=
new
HashMap
<
ProductLine
,
List
<
MetricItemConfig
>>();
for
(
Entry
<
String
,
ProductLine
>
entry
:
productLins
.
entrySet
())
{
Set
<
String
>
domains
=
entry
.
getValue
().
getDomains
().
keySet
();
List
<
MetricItemConfig
>
configs
=
m_metricConfigManager
.
queryMetricItemConfigs
(
domains
);
metricConfigs
.
put
(
entry
.
getValue
(),
configs
);
}
model
.
setProductMetricConfigs
(
metricConfigs
);
}
private
List
<
Project
>
queryAllProjects
()
{
List
<
Project
>
projects
=
new
ArrayList
<
Project
>();
...
...
@@ -259,7 +317,7 @@ public class Handler implements PageHandler<Context> {
}
}
class
ProjectCompartor
implements
Comparator
<
Project
>
{
public
static
class
ProjectCompartor
implements
Comparator
<
Project
>
{
@Override
public
int
compare
(
Project
o1
,
Project
o2
)
{
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/JspFile.java
浏览文件 @
8270cfe7
...
...
@@ -19,7 +19,13 @@ public enum JspFile {
TOPOLOGY_GRAPH_PRODUCT_LINE
(
"/jsp/system/productLine/topologyProductLines.jsp"
),
TOPOLOGY_GRAPH_PRODUCT_ADD_OR_UPDATE
(
"/jsp/system/productLine/topologyProductLineAdd.jsp"
),
TOPOLOGY_GRAPH_PRODUCT_ADD_OR_UPDATE
(
"/jsp/system/productLine/topologyProductLineAdd.jsp"
),
METRIC_CONFIG_ADD_OR_UPDATE
(
"/jsp/system/metric/metricConfigAdd.jsp"
),
METRIC_CONFIG_ADD_OR_UPDATE_SUBMIT
(
"/jsp/system/metric/metricConfigs.jsp"
),
METRIC_CONFIG_LIST
(
"/jsp/system/metric/metricConfigs.jsp"
)
;
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/JspViewer.java
浏览文件 @
8270cfe7
...
...
@@ -51,6 +51,15 @@ public class JspViewer extends BaseJspViewer<SystemPage, Action, Context, Model>
return
JspFile
.
TOPOLOGY_GRAPH_PRODUCT_LINE
.
getPath
();
case
TOPOLOGY_GRAPH_PRODUCT_LINE_ADD_OR_UPDATE_SUBMIT:
return
JspFile
.
TOPOLOGY_GRAPH_PRODUCT_LINE
.
getPath
();
case
METRIC_CONFIG_ADD_OR_UPDATE:
return
JspFile
.
METRIC_CONFIG_ADD_OR_UPDATE
.
getPath
();
case
METRIC_CONFIG_ADD_OR_UPDATE_SUBMIT:
return
JspFile
.
METRIC_CONFIG_ADD_OR_UPDATE_SUBMIT
.
getPath
();
case
METRIC_CONFIG_LIST:
return
JspFile
.
METRIC_CONFIG_LIST
.
getPath
();
case
METRIC_CONFIG_DELETE:
return
JspFile
.
METRIC_CONFIG_LIST
.
getPath
();
}
throw
new
RuntimeException
(
"Unknown action: "
+
action
);
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/Model.java
浏览文件 @
8270cfe7
...
...
@@ -8,6 +8,7 @@ import java.util.Map;
import
org.unidal.web.mvc.ViewModel
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.consumer.aggreation.model.entity.AggregationRule
;
import
com.dianping.cat.consumer.company.model.entity.ProductLine
;
import
com.dianping.cat.consumer.core.dal.Project
;
...
...
@@ -41,6 +42,10 @@ public class Model extends ViewModel<SystemPage, Action, Context> {
private
ProductLine
m_productLine
;
private
Map
<
String
,
ProductLine
>
m_productLines
;
private
MetricItemConfig
m_metricItemConfig
;
private
Map
<
ProductLine
,
List
<
MetricItemConfig
>>
m_productMetricConfigs
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
...
...
@@ -174,6 +179,22 @@ public class Model extends ViewModel<SystemPage, Action, Context> {
public
void
setProjects
(
List
<
Project
>
projects
)
{
m_projects
=
projects
;
}
public
MetricItemConfig
getMetricItemConfig
()
{
return
m_metricItemConfig
;
}
public
void
setMetricItemConfig
(
MetricItemConfig
metricItemConfig
)
{
m_metricItemConfig
=
metricItemConfig
;
}
public
Map
<
ProductLine
,
List
<
MetricItemConfig
>>
getProductMetricConfigs
()
{
return
m_productMetricConfigs
;
}
public
void
setProductMetricConfigs
(
Map
<
ProductLine
,
List
<
MetricItemConfig
>>
productMetricConfigs
)
{
m_productMetricConfigs
=
productMetricConfigs
;
}
public
static
class
Edge
{
private
List
<
EdgeConfig
>
m_edgeConfigs
;
...
...
cat-home/src/main/java/com/dianping/cat/system/page/config/Payload.java
浏览文件 @
8270cfe7
...
...
@@ -5,6 +5,7 @@ import org.unidal.web.mvc.ActionPayload;
import
org.unidal.web.mvc.payload.annotation.FieldMeta
;
import
org.unidal.web.mvc.payload.annotation.ObjectMeta
;
import
com.dianping.cat.advanced.metric.config.entity.MetricItemConfig
;
import
com.dianping.cat.consumer.aggreation.model.entity.AggregationRule
;
import
com.dianping.cat.consumer.company.model.entity.ProductLine
;
import
com.dianping.cat.consumer.core.dal.Project
;
...
...
@@ -33,6 +34,9 @@ public class Payload implements ActionPayload<SystemPage, Action> {
@ObjectMeta
(
"edgeConfig"
)
private
EdgeConfig
m_edgeConfig
=
new
EdgeConfig
();
@ObjectMeta
(
"metricItemConfig"
)
private
MetricItemConfig
m_metricItemConfig
=
new
MetricItemConfig
();
@FieldMeta
(
"projectId"
)
private
int
m_projectId
;
...
...
@@ -51,12 +55,15 @@ public class Payload implements ActionPayload<SystemPage, Action> {
@FieldMeta
(
"id"
)
private
int
m_id
;
@FieldMeta
(
"metricKey"
)
private
String
m_metricKey
;
@FieldMeta
(
"type"
)
private
String
m_type
;
@FieldMeta
(
"to"
)
private
String
m_to
;
@FieldMeta
(
"pattern"
)
private
String
m_pattern
;
...
...
@@ -98,8 +105,8 @@ public class Payload implements ActionPayload<SystemPage, Action> {
}
public
String
getPattern
()
{
return
m_pattern
;
}
return
m_pattern
;
}
public
ProductLine
getProductLine
()
{
return
m_productLine
;
...
...
@@ -167,8 +174,8 @@ public class Payload implements ActionPayload<SystemPage, Action> {
}
public
void
setPattern
(
String
pattern
)
{
m_pattern
=
pattern
;
}
m_pattern
=
pattern
;
}
public
void
setProductLine
(
ProductLine
productLine
)
{
m_productLine
=
productLine
;
...
...
@@ -211,4 +218,20 @@ public class Payload implements ActionPayload<SystemPage, Action> {
public
void
validate
(
ActionContext
<?>
ctx
)
{
}
public
MetricItemConfig
getMetricItemConfig
()
{
return
m_metricItemConfig
;
}
public
void
setMetricItemConfig
(
MetricItemConfig
metricItemConfig
)
{
m_metricItemConfig
=
metricItemConfig
;
}
public
String
getMetricKey
()
{
return
m_metricKey
;
}
public
void
setMetricKey
(
String
metricKey
)
{
m_metricKey
=
metricKey
;
}
}
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
8270cfe7
...
...
@@ -3099,6 +3099,9 @@
<requirement>
<role>
com.dianping.cat.consumer.core.aggregation.AggregationConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.advanced.MetricConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.report.view.DomainNavManager
</role>
</requirement>
...
...
cat-home/src/main/resources/config/default-metric-config.xml
浏览文件 @
8270cfe7
<metric-config>
<metric-item-config
id=
"TuanGouWeb:/index"
domain=
"TuanGouWeb"
type=
"URL"
view-order=
"1"
metric-key=
"/index"
title=
"团购首页"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
<metric-item-config
id=
"TuanGouWeb:/detail"
domain=
"TuanGouWeb"
type=
"URL"
view-order=
"1"
metric-key=
"/detail"
title=
"团购详情"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
<metric-item-config
id=
"
TuanGouWeb:/order/submitOrder"
domain=
"PayOrder"
type=
"URL"
view-order=
"1"
metric-key=
"/index
"
title=
"团购支付"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
<metric-item-config
id=
"Cat:t"
domain=
"Cat"
type=
"URL"
view-order=
"1"
metric-key=
"t"
title=
"transaction"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
<metric-item-config
id=
"Cat:home"
domain=
"Cat"
type=
"URL"
view-order=
"1"
metric-key=
"home"
title=
"home"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
<metric-item-config
id=
"TuanGouWeb:
URL:
/index"
domain=
"TuanGouWeb"
type=
"URL"
view-order=
"1"
metric-key=
"/index"
title=
"团购首页"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
<metric-item-config
id=
"TuanGouWeb:
URL:
/detail"
domain=
"TuanGouWeb"
type=
"URL"
view-order=
"1"
metric-key=
"/detail"
title=
"团购详情"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
<metric-item-config
id=
"
PayOrder:URL:/order/submitOrder"
domain=
"PayOrder"
type=
"URL"
view-order=
"1"
metric-key=
"/order/submitOrder
"
title=
"团购支付"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
<metric-item-config
id=
"Cat:
URL:
t"
domain=
"Cat"
type=
"URL"
view-order=
"1"
metric-key=
"t"
title=
"transaction"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
<metric-item-config
id=
"Cat:
URL:
home"
domain=
"Cat"
type=
"URL"
view-order=
"1"
metric-key=
"home"
title=
"home"
show-count=
"true"
show-avg=
"false"
show-sum=
"false"
></metric-item-config>
</metric-config>
cat-home/src/main/webapp/jsp/system/configTree.jsp
浏览文件 @
8270cfe7
...
...
@@ -10,7 +10,7 @@
<li
class=
"text-right"
id=
"topylogyNodeConfigList"
><a
href=
"?op=topologyGraphNodeConfigList"
><strong>
拓扑节点阀值
</strong></a></li>
<li
class=
"text-right"
id=
"topylogyEdgeConfigList"
><a
href=
"?op=topologyGraphEdgeConfigList"
><strong>
拓扑依赖阀值
</strong></a></li>
<li
class=
'nav-header'
><h4>
业务监控配置
</h4></li>
<li
class=
"text-right"
id=
"
bussinessConfigList"
><a
href=
"?
"
><strong>
业务监控规则
</strong></a></li>
<li
class=
"text-right"
id=
"
metricConfigList"
><a
href=
"?op=metricConfigList
"
><strong>
业务监控规则
</strong></a></li>
</ul>
</div>
<style>
...
...
cat-home/src/main/webapp/jsp/system/metric/metricConfigAdd.jsp
0 → 100644
浏览文件 @
8270cfe7
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"res"
uri=
"http://www.unidal.org/webres"
%>
<%@ taglib
prefix=
"w"
uri=
"http://www.unidal.org/web/core"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.system.page.config.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.system.page.config.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.system.page.config.Model"
scope=
"request"
/>
<form
name=
"metricConfigAddSumbit"
id=
"form"
method=
"post"
action=
"${model.pageUri}?op=metricConfigAddSumbit"
>
<h4
class=
"text-center text-error"
id=
"state"
>
</h4>
<h4
class=
"text-center text-error"
>
修改业务监控节点配置信息
</h4>
<input
name=
"productLineName"
value=
"${payload.productLineName}"
type=
"hidden"
/>
<table
class=
"table table-striped table-bordered table-condensed"
>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
项目名称
</td>
<td>
<c:if
test=
"
${
not
empty
model
.
metricItemConfig
.
domain
}
"
>
<input
name=
"metricItemConfig.domain"
value=
"${model.metricItemConfig.domain}"
readonly
required
/>
</c:if>
<c:if
test=
"
${
empty
model
.
metricItemConfig
.
domain
}
"
>
<select
style=
"width:200px;"
name=
"metricItemConfig.domain"
id=
"id"
>
<c:forEach
var=
"item"
items=
"
${
model
.
projects
}
"
>
<option
value=
"${item.domain}"
>
${item.domain}
</option>
</c:forEach>
</select>
</c:if>
</td>
</tr>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
类型
</td>
<td>
<c:if
test=
"
${
not
empty
model
.
metricItemConfig
.
domain
}
"
>
<input
name=
"metricItemConfig.type"
value=
"${model.metricItemConfig.type}"
readonly
required
/>
</c:if>
<c:if
test=
"
${
empty
model
.
metricItemConfig
.
type
}
"
>
<input
name=
"metricItemConfig.type"
value=
"${model.metricItemConfig.type}"
required
/>
</c:if>
</tr>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
MetricKey
</td>
<td>
<c:if
test=
"
${
not
empty
model
.
metricItemConfig
.
domain
}
"
>
<input
name=
"metricItemConfig.metricKey"
value=
"${model.metricItemConfig.metricKey}"
readonly
required
/>
</c:if>
<c:if
test=
"
${
empty
model
.
metricItemConfig
.
type
}
"
>
<input
name=
"metricItemConfig.metricKey"
value=
"${model.metricItemConfig.metricKey}"
required
/>
</c:if>
</td>
</tr>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
显示顺序
</td>
<td><input
name=
"metricItemConfig.viewOrder"
value=
"${model.metricItemConfig.viewOrder}"
required
/></td>
</tr>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
显示标题
</td>
<td><input
name=
"metricItemConfig.title"
value=
"${model.metricItemConfig.title}"
required
/></td>
</tr>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
显示次数曲线
</td>
<td>
<c:choose>
<c:when
test=
"
${
model
.
metricItemConfig
.
showCount
}
"
>
<input
type=
"radio"
name=
"metricItemConfig.showCount"
value=
"true"
checked
/>
是
<input
type=
"radio"
name=
"metricItemConfig.showCount"
value=
"false"
/>
否
</c:when>
<c:otherwise>
<input
type=
"radio"
name=
"metricItemConfig.showCount"
value=
"true"
/>
是
<input
type=
"radio"
name=
"metricItemConfig.showCount"
value=
"false"
checked
/>
否
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
显示平均曲线
</td>
<td>
<c:choose>
<c:when
test=
"
${
model
.
metricItemConfig
.
showAvg
}
"
>
<input
type=
"radio"
name=
"metricItemConfig.showAvg"
value=
"true"
checked
/>
是
<input
type=
"radio"
name=
"metricItemConfig.showAvg"
value=
"false"
/>
否
</c:when>
<c:otherwise>
<input
type=
"radio"
name=
"metricItemConfig.showAvg"
value=
"true"
/>
是
<input
type=
"radio"
name=
"metricItemConfig.showAvg"
value=
"false"
checked
/>
否
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td
style=
"text-align:right"
class=
"text-success"
>
显示求和曲线
</td>
<td>
<c:choose>
<c:when
test=
"
${
model
.
metricItemConfig
.
showAvg
}
"
>
<input
type=
"radio"
name=
"metricItemConfig.showSum"
value=
"true"
checked
/>
是
<input
type=
"radio"
name=
"metricItemConfig.showSum"
value=
"false"
/>
否
</c:when>
<c:otherwise>
<input
type=
"radio"
name=
"metricItemConfig.showSum"
value=
"true"
/>
是
<input
type=
"radio"
name=
"metricItemConfig.showSum"
value=
"false"
checked
/>
否
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td>
</td>
<td><input
class=
'btn btn-primary'
id=
"addOrUpdateNodeSubmit"
type=
"submit"
name=
"submit"
value=
"提交"
/></td>
</tr>
</table>
</form>
\ No newline at end of file
cat-home/src/main/webapp/jsp/system/metric/metricConfigs.jsp
0 → 100644
浏览文件 @
8270cfe7
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"res"
uri=
"http://www.unidal.org/webres"
%>
<%@ taglib
prefix=
"w"
uri=
"http://www.unidal.org/web/core"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.system.page.config.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.system.page.config.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.system.page.config.Model"
scope=
"request"
/>
<a:body>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jquery.validate.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'alarm_js'
]
}
"
target=
"head-js"
/>
<res:useCss
value=
"
${
res
.
css
.
local
[
'select2.css'
]
}
"
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'select2.min.js'
]
}
"
target=
"head-js"
/>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
#metricConfigList
'
).
addClass
(
'
active
'
);
var
productLine
=
'
${payload.productLineName}
'
;
if
(
productLine
==
''
){
productLine
=
'
TuanGou
'
;
}
$
(
'
#tab-
'
+
productLine
).
addClass
(
'
active
'
);
$
(
'
#tabContent-
'
+
productLine
).
addClass
(
'
active
'
);
$
(
"
.delete
"
).
bind
(
"
click
"
,
function
()
{
return
confirm
(
"
确定要删除此项目吗(不可恢复)?
"
);
});
$
(
document
).
delegate
(
'
.update
'
,
'
click
'
,
function
(
e
){
var
anchor
=
this
,
el
=
$
(
anchor
);
if
(
e
.
ctrlKey
||
e
.
metaKey
){
return
true
;
}
else
{
e
.
preventDefault
();
}
//var cell = document.getElementById('');
$
.
ajax
({
type
:
"
get
"
,
url
:
anchor
.
href
,
success
:
function
(
response
,
textStatus
)
{
$
(
'
#myModal
'
).
html
(
response
);
$
(
'
#myModal
'
).
modal
();
$
(
"
#id
"
).
select2
();
}
});
});
var
action
=
'
${payload.action.name}
'
;
if
(
action
==
'
metricConfigDelete
'
||
action
==
'
metricConfigAddSumbit
'
){
var
state
=
'
${model.opState}
'
;
if
(
state
==
'
Success
'
){
$
(
'
#state
'
).
html
(
'
操作成功
'
);
}
else
{
$
(
'
#state
'
).
html
(
'
操作失败
'
);
}
setInterval
(
function
(){
$
(
'
#state
'
).
html
(
'
'
);
},
3000
);
}
});
</script>
<div
class=
"row-fluid"
>
<div
class=
"span2"
>
<%@include
file=
"../configTree.jsp"
%>
</div>
<div
class=
"span10"
>
<!-- Modal -->
<div
id=
"myModal"
class=
"modal hide fade"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
>
</div>
<h4
id=
"state"
class=
"text-center text-error"
>
</h4>
<div
class=
"tabbable tabs-left"
id=
"content"
>
<!-- Only required for left/right tabs -->
<ul
class=
"nav nav-tabs"
>
<c:forEach
var=
"item"
items=
"
${
model
.
productMetricConfigs
}
"
varStatus=
"status"
>
<c:set
var=
"product"
value=
"
${
item
.
key
}
"
/>
<c:set
var=
"key"
value=
"
${
product
.
id
}
"
/>
<li
id=
"tab-${key}"
class=
"text-right"
><a
href=
"#tabContent-${key}"
data-toggle=
"tab"
>
<h5
class=
"text-error"
>
${product.title}
</h5></a></li>
</c:forEach>
</ul>
<div
class=
"tab-content"
>
<c:forEach
var=
"item"
items=
"
${
model
.
productMetricConfigs
}
"
varStatus=
"status"
>
<c:set
var=
"product"
value=
"
${
item
.
key
}
"
/>
<c:set
var=
"key"
value=
"
${
product
.
id
}
"
/>
<c:set
var=
"value"
value=
"
${
item
.
value
}
"
/>
<div
class=
"tab-pane"
id=
"tabContent-${key}"
>
<h4
class=
"text-center text-error"
>
${product.title}:产品线内业务监控配置
</h4>
<table
class=
"table table-striped table-bordered table-condensed"
>
<tr
class=
"text-success"
>
<th><h5
class=
'text-center'
>
项目
</h5></th>
<th><h5
class=
'text-center'
>
类型
</h5></th>
<th><h5
class=
'text-center'
>
显示顺序
</h5></th>
<th><h5
class=
'text-center'
>
MetricKey
</h5></th>
<th><h5
class=
'text-center'
>
标题
</h5></th>
<th><h5
class=
'text-center'
>
显示次数
</h5></th>
<th><h5
class=
'text-center'
>
显示平均值
</h5></th>
<th><h5
class=
'text-center'
>
显示总和
</h5></th>
<th><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>
<td>
${config.domain}
</td>
<td>
${config.type}
</td>
<td>
${config.viewOrder}
</td>
<td>
${config.metricKey}
</td>
<td>
${config.title}
</td>
<td>
${config.showCount}
</td>
<td>
${config.showAvg}
</td>
<td>
${config.showSum}
</td>
<td
style=
"text-align:center"
>
<a
href=
"?op=metricConfigAdd&metricKey=${config.metricKey}&type=${config.type}&domain=${config.domain}&productLineName=${key}"
class=
"btn update btn-primary btn-small"
>
修改
</a>
<a
href=
"?op=metricConfigDelete&metricKey=${config.metricKey}&type=${config.type}&domain=${config.domain}&productLineName=${key}"
class=
"btn btn-primary btn-small btn-danger delete"
>
删除
</a>
</td>
</tr>
</c:forEach>
</table>
</div>
</c:forEach>
</div>
</div>
</div>
</div>
</a:body>
\ No newline at end of file
cat-home/src/test/java/com/dianping/cat/demo/TestABTestBusinessMessage.java
浏览文件 @
8270cfe7
...
...
@@ -49,6 +49,9 @@ public class TestABTestBusinessMessage {
Cat
.
logMetricForCount
(
"order"
);
Cat
.
logMetricForDuration
(
"time"
,
500
);
Cat
.
logMetricForSum
(
"payment.success"
,
i
);
Cat
.
logMetricForSum
(
"Order1"
,
i
);
Cat
.
logMetricForSum
(
"Order2"
,
i
);
Cat
.
logMetricForSum
(
"Order1-10"
,
i
);
DefaultMessageTree
tree
=
(
DefaultMessageTree
)
Cat
.
getManager
().
getThreadLocalMessageTree
();
tree
.
setDomain
(
PayOrder
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录