Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
8b08e8d6
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,发现更多精彩内容 >>
提交
8b08e8d6
编写于
5月 16, 2013
作者:
Y
yong.you
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refator metric problem
上级
ea9c917c
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
608 addition
and
243 deletion
+608
-243
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/BussinessConfigManager.java
...ianping/cat/consumer/advanced/BussinessConfigManager.java
+331
-0
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
...va/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
+60
-61
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
...m/dianping/cat/consumer/build/ComponentsConfigurator.java
+8
-5
cat-consumer-advanced/src/main/resources/META-INF/plexus/components.xml
...dvanced/src/main/resources/META-INF/plexus/components.xml
+7
-0
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
...ain/java/com/dianping/cat/report/page/metric/Handler.java
+15
-36
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricConfig.java
...ava/com/dianping/cat/report/page/metric/MetricConfig.java
+0
-86
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricDisplay.java
...va/com/dianping/cat/report/page/metric/MetricDisplay.java
+27
-23
cat-home/src/main/java/com/dianping/cat/report/page/metric/Model.java
.../main/java/com/dianping/cat/report/page/metric/Model.java
+30
-0
cat-home/src/main/java/com/dianping/cat/report/page/metric/Payload.java
...ain/java/com/dianping/cat/report/page/metric/Payload.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/transaction/TransactionMergeManager.java
.../cat/report/page/transaction/TransactionMergeManager.java
+1
-0
cat-home/src/main/java/com/dianping/cat/report/task/spi/ReportFacade.java
...n/java/com/dianping/cat/report/task/spi/ReportFacade.java
+11
-6
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
...main/java/com/dianping/cat/report/view/NavigationBar.java
+4
-4
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+7
-0
cat-home/src/main/webapp/jsp/report/metric.jsp
cat-home/src/main/webapp/jsp/report/metric.jsp
+40
-17
cat-home/src/test/java/com/dianping/cat/demo/TestBusinessMessage.java
.../test/java/com/dianping/cat/demo/TestBusinessMessage.java
+66
-4
未找到文件。
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/BussinessConfigManager.java
0 → 100644
浏览文件 @
8b08e8d6
package
com.dianping.cat.consumer.advanced
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
public
class
BussinessConfigManager
implements
Initializable
{
// key is domain
private
Map
<
String
,
Map
<
Integer
,
List
<
BusinessConfig
>>>
m_configs
=
new
ConcurrentHashMap
<
String
,
Map
<
Integer
,
List
<
BusinessConfig
>>>();
// key is group
private
Map
<
String
,
List
<
BusinessConfig
>>
m_groupConfigs
=
new
ConcurrentHashMap
<
String
,
List
<
BusinessConfig
>>();
private
Map
<
String
,
String
>
m_domainGroup
=
new
ConcurrentHashMap
<
String
,
String
>();
private
Set
<
String
>
m_groups
=
new
TreeSet
<
String
>();
public
Set
<
String
>
getGroups
()
{
return
m_groups
;
}
public
List
<
BusinessConfig
>
getUrlConfigs
(
String
domain
)
{
return
getMetricConfigsByType
(
domain
,
BusinessConfig
.
URL
);
}
public
List
<
BusinessConfig
>
getMetricConfigs
(
String
domain
)
{
return
getMetricConfigsByType
(
domain
,
BusinessConfig
.
METRIC
);
}
public
List
<
BusinessConfig
>
getConfigs
(
String
group
)
{
List
<
BusinessConfig
>
list
=
m_groupConfigs
.
get
(
group
);
if
(
list
!=
null
)
{
Collections
.
sort
(
list
,
new
BusinessConfigCompator
());
return
list
;
}
else
{
return
new
ArrayList
<
BusinessConfig
>();
}
}
private
List
<
BusinessConfig
>
getMetricConfigsByType
(
String
domain
,
int
type
)
{
Map
<
Integer
,
List
<
BusinessConfig
>>
configMap
=
m_configs
.
get
(
domain
);
if
(
configMap
!=
null
)
{
List
<
BusinessConfig
>
config
=
configMap
.
get
(
type
);
if
(
config
!=
null
)
{
return
config
;
}
}
return
new
ArrayList
<
BusinessConfig
>();
}
private
BussinessConfigManager
addConfig
(
BusinessConfig
config
)
{
String
domain
=
config
.
getDomain
();
Map
<
Integer
,
List
<
BusinessConfig
>>
configsMap
=
m_configs
.
get
(
domain
);
if
(
configsMap
==
null
)
{
configsMap
=
new
ConcurrentHashMap
<
Integer
,
List
<
BusinessConfig
>>();
m_configs
.
put
(
config
.
getDomain
(),
configsMap
);
}
int
type
=
config
.
getType
();
List
<
BusinessConfig
>
configs
=
configsMap
.
get
(
type
);
if
(
configs
==
null
)
{
configs
=
new
ArrayList
<
BusinessConfig
>();
configsMap
.
put
(
config
.
getType
(),
configs
);
}
configs
.
add
(
config
);
String
group
=
config
.
getGroup
();
List
<
BusinessConfig
>
groupConfigs
=
m_groupConfigs
.
get
(
group
);
if
(
groupConfigs
==
null
)
{
groupConfigs
=
new
ArrayList
<
BusinessConfig
>();
m_groupConfigs
.
put
(
group
,
groupConfigs
);
}
groupConfigs
.
add
(
config
);
m_domainGroup
.
put
(
domain
,
group
);
return
this
;
}
@Override
public
void
initialize
()
throws
InitializationException
{
String
TuanGou
=
"TuanGou"
;
String
TuanGouWeb
=
"TuanGouWeb"
;
String
PayOrder
=
"PayOrder"
;
String
Cat
=
"Cat"
;
// tuangou.put("order", "quantity");
// tuangou.put("payment.pending", "amount");
// tuangou.put("payment.success", "amount");
m_groups
.
add
(
Cat
);
m_groups
.
add
(
TuanGou
);
BusinessConfig
config
=
new
BusinessConfig
();
config
.
setGroup
(
Cat
).
setDomain
(
Cat
).
setType
(
BusinessConfig
.
URL
);
config
.
setViewOrder
(
1
).
setMainKey
(
"t"
).
setClassifications
(
null
);
config
.
setTitle
(
"Transaction"
).
setShowCount
(
true
).
setShowAvg
(
true
).
setShowSum
(
true
);
addConfig
(
config
);
config
=
new
BusinessConfig
();
config
.
setGroup
(
Cat
).
setDomain
(
Cat
).
setType
(
BusinessConfig
.
URL
);
config
.
setViewOrder
(
2
).
setMainKey
(
"e"
).
setClassifications
(
null
);
config
.
setTitle
(
"Event"
).
setShowCount
(
true
).
setShowAvg
(
false
).
setShowSum
(
false
);
addConfig
(
config
);
config
=
new
BusinessConfig
();
config
.
setGroup
(
Cat
).
setDomain
(
Cat
).
setType
(
BusinessConfig
.
URL
);
config
.
setViewOrder
(
3
).
setMainKey
(
"home"
).
setClassifications
(
null
);
config
.
setTitle
(
"Home"
).
setShowCount
(
true
).
setShowAvg
(
false
).
setShowSum
(
false
);
addConfig
(
config
);
config
=
new
BusinessConfig
();
config
.
setGroup
(
TuanGou
).
setDomain
(
TuanGouWeb
).
setType
(
BusinessConfig
.
URL
);
config
.
setViewOrder
(
1
).
setMainKey
(
"/index"
).
setClassifications
(
"channel"
);
config
.
setTitle
(
MetricTitle
.
INDEX
).
setShowCount
(
true
).
setShowAvg
(
false
).
setShowSum
(
false
);
addConfig
(
config
);
config
=
new
BusinessConfig
();
config
.
setGroup
(
TuanGou
).
setDomain
(
TuanGouWeb
).
setType
(
BusinessConfig
.
URL
);
config
.
setViewOrder
(
2
).
setMainKey
(
"/detail"
).
setClassifications
(
"channel"
);
config
.
setTitle
(
MetricTitle
.
DETAIL
).
setShowCount
(
true
).
setShowAvg
(
false
).
setShowSum
(
false
);
addConfig
(
config
);
config
=
new
BusinessConfig
();
config
.
setGroup
(
TuanGou
).
setDomain
(
PayOrder
).
setType
(
BusinessConfig
.
URL
);
config
.
setViewOrder
(
3
).
setMainKey
(
"/order/submitOrder"
).
setClassifications
(
"channel"
);
config
.
setTitle
(
MetricTitle
.
PAY
).
setShowCount
(
true
).
setShowAvg
(
false
).
setShowSum
(
false
);
addConfig
(
config
);
config
=
new
BusinessConfig
();
config
.
setGroup
(
TuanGou
).
setDomain
(
PayOrder
).
setType
(
BusinessConfig
.
METRIC
);
config
.
setViewOrder
(
4
).
setMainKey
(
"order"
).
setClassifications
(
"channel"
).
setTarget
(
"quantity"
);
config
.
setTitle
(
MetricTitle
.
ORDER
).
setShowCount
(
true
).
setShowAvg
(
false
).
setShowSum
(
false
);
addConfig
(
config
);
config
=
new
BusinessConfig
();
config
.
setGroup
(
TuanGou
).
setDomain
(
PayOrder
).
setType
(
BusinessConfig
.
METRIC
);
config
.
setViewOrder
(
5
).
setMainKey
(
"payment.pending"
).
setClassifications
(
"channel"
).
setTarget
(
"amount"
);
config
.
setTitle
(
MetricTitle
.
SUCCESS
).
setShowCount
(
false
).
setShowAvg
(
false
).
setShowSum
(
false
);
addConfig
(
config
);
config
=
new
BusinessConfig
();
config
.
setGroup
(
TuanGou
).
setDomain
(
PayOrder
).
setType
(
BusinessConfig
.
METRIC
);
config
.
setViewOrder
(
6
).
setMainKey
(
"payment.success"
).
setClassifications
(
"channel"
).
setTarget
(
"amount"
);
config
.
setTitle
(
MetricTitle
.
SUCCESS
).
setShowCount
(
true
).
setShowAvg
(
false
).
setShowSum
(
true
);
addConfig
(
config
);
}
public
static
class
BusinessConfigCompator
implements
Comparator
<
BusinessConfig
>
{
@Override
public
int
compare
(
BusinessConfig
o1
,
BusinessConfig
o2
)
{
return
o1
.
getViewOrder
()
-
o2
.
getViewOrder
();
}
}
public
static
class
BusinessConfig
{
public
static
final
int
URL
=
1
;
public
static
final
int
METRIC
=
2
;
public
static
final
String
Suffix_SUM
=
"(总和)"
;
public
static
final
String
Suffix_COUNT
=
"(次数)"
;
public
static
final
String
Suffix_AVG
=
"(平均)"
;
private
String
m_group
;
private
String
m_domain
;
private
int
m_type
;
private
int
m_viewOrder
;
private
String
m_mainKey
;
private
String
m_target
;
private
String
m_classifications
;
private
String
m_title
;
private
boolean
m_showSum
;
private
boolean
m_showCount
;
private
boolean
m_showAvg
;
public
String
getTarget
()
{
return
m_target
;
}
public
BusinessConfig
setTarget
(
String
target
)
{
m_target
=
target
;
return
this
;
}
public
String
getClassifications
()
{
return
m_classifications
;
}
public
String
getDomain
()
{
return
m_domain
;
}
public
String
getGroup
()
{
return
m_group
;
}
public
String
getMainKey
()
{
return
m_mainKey
;
}
public
String
getTitle
()
{
return
m_title
;
}
public
int
getType
()
{
return
m_type
;
}
public
int
getViewOrder
()
{
return
m_viewOrder
;
}
public
boolean
isShowAvg
()
{
return
m_showAvg
;
}
public
boolean
isShowCount
()
{
return
m_showCount
;
}
public
boolean
isShowSum
()
{
return
m_showSum
;
}
public
BusinessConfig
setClassifications
(
String
childKeys
)
{
m_classifications
=
childKeys
;
return
this
;
}
public
BusinessConfig
setDomain
(
String
domain
)
{
m_domain
=
domain
;
return
this
;
}
public
BusinessConfig
setGroup
(
String
group
)
{
m_group
=
group
;
return
this
;
}
public
BusinessConfig
setMainKey
(
String
mainKey
)
{
m_mainKey
=
mainKey
;
return
this
;
}
public
BusinessConfig
setShowAvg
(
boolean
showAvg
)
{
m_showAvg
=
showAvg
;
return
this
;
}
public
BusinessConfig
setShowCount
(
boolean
showCount
)
{
m_showCount
=
showCount
;
return
this
;
}
public
BusinessConfig
setShowSum
(
boolean
showSum
)
{
m_showSum
=
showSum
;
return
this
;
}
public
BusinessConfig
setTitle
(
String
title
)
{
m_title
=
title
;
return
this
;
}
public
BusinessConfig
setType
(
int
type
)
{
m_type
=
type
;
return
this
;
}
public
BusinessConfig
setViewOrder
(
int
viewOrder
)
{
m_viewOrder
=
viewOrder
;
return
this
;
}
}
public
class
MetricTitle
{
public
static
final
String
INDEX
=
"团购首页"
;
public
static
final
String
DETAIL
=
"团购详情"
;
public
static
final
String
PAY
=
"支付页面"
;
public
static
final
String
ORDER
=
"订单创建"
;
public
static
final
String
SUCCESS
=
"支付金额(单位:元)"
;
}
public
String
getGroup
(
String
domain
)
{
return
m_domainGroup
.
get
(
domain
);
}
}
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
浏览文件 @
8b08e8d6
...
...
@@ -2,7 +2,6 @@ package com.dianping.cat.consumer.advanced;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -17,6 +16,7 @@ import com.dianping.cat.Cat;
import
com.dianping.cat.CatConstants
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.consumer.AbstractMessageAnalyzer
;
import
com.dianping.cat.consumer.advanced.BussinessConfigManager.BusinessConfig
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.consumer.metric.model.entity.Point
;
import
com.dianping.cat.consumer.metric.model.transform.DefaultNativeBuilder
;
...
...
@@ -38,35 +38,12 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
@Inject
private
BusinessReportDao
m_businessReportDao
;
@Inject
private
BussinessConfigManager
m_configManager
;
// key is project line,such as tuangou
private
Map
<
String
,
MetricReport
>
m_reports
=
new
HashMap
<
String
,
MetricReport
>();
private
static
final
String
TUANGOU
=
"TuanGou"
;
private
static
final
String
CHANNEL
=
"channel"
;
private
static
Map
<
String
,
Set
<
String
>>
s_urls
=
new
HashMap
<
String
,
Set
<
String
>>();
private
static
Map
<
String
,
Map
<
String
,
String
>>
s_metric
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
static
{
Set
<
String
>
urls
=
new
HashSet
<
String
>();
urls
.
add
(
"/index"
);
urls
.
add
(
"/detail"
);
urls
.
add
(
"/order/submitOrder"
);
s_urls
.
put
(
TUANGOU
,
urls
);
}
static
{
Map
<
String
,
String
>
tuangou
=
new
HashMap
<
String
,
String
>();
tuangou
.
put
(
"order"
,
"quantity"
);
tuangou
.
put
(
"payment.pending"
,
"amount"
);
tuangou
.
put
(
"payment.success"
,
"amount"
);
s_metric
.
put
(
TUANGOU
,
tuangou
);
}
@Override
public
void
doCheckpoint
(
boolean
atEnd
)
{
storeReports
(
atEnd
);
...
...
@@ -82,10 +59,6 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
return
m_reports
.
keySet
();
}
public
String
getGroup
(
String
domain
)
{
return
"TuanGou"
;
}
public
MetricReport
getReport
(
String
group
)
{
MetricReport
report
=
m_reports
.
get
(
group
);
...
...
@@ -124,8 +97,7 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
@Override
public
void
process
(
MessageTree
tree
)
{
String
domain
=
tree
.
getDomain
();
String
group
=
getGroup
(
domain
);
String
group
=
m_configManager
.
getGroup
(
domain
);
MetricReport
report
=
m_reports
.
get
(
group
);
if
(
report
==
null
)
{
...
...
@@ -139,7 +111,7 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
Message
message
=
tree
.
getMessage
();
if
(
message
instanceof
Transaction
)
{
processUrl
(
group
,
report
,
(
Transaction
)
message
);
processUrl
(
group
,
report
,
(
Transaction
)
message
,
tree
);
}
if
(
message
instanceof
Transaction
)
{
processTransaction
(
group
,
report
,
tree
,
(
Transaction
)
message
);
...
...
@@ -148,35 +120,50 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
}
}
private
void
processUrl
(
String
group
,
MetricReport
report
,
Transaction
transaction
)
{
Set
<
String
>
urls
=
s_urls
.
get
(
group
);
private
void
processUrl
(
String
group
,
MetricReport
report
,
Transaction
transaction
,
MessageTree
tree
)
{
String
type
=
transaction
.
getType
();
String
name
=
transaction
.
getName
();
if
(
type
.
equals
(
CatConstants
.
TYPE_URL
)
&&
urls
.
contains
(
name
))
{
long
current
=
transaction
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
if
(
CatConstants
.
TYPE_URL
.
equals
(
type
))
{
String
name
=
transaction
.
getName
();
String
domain
=
tree
.
getDomain
();
List
<
BusinessConfig
>
configs
=
m_configManager
.
getUrlConfigs
(
domain
);
BusinessConfig
config
=
null
;
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
metric
=
report
.
findOrCreateMetric
(
name
);
Point
point
=
metric
.
findOrCreatePoint
(
min
);
for
(
BusinessConfig
c
:
configs
)
{
if
(
c
.
getMainKey
().
equals
(
name
))
{
config
=
c
;
break
;
}
}
if
(
config
!=
null
)
{
long
current
=
transaction
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
point
.
setCount
(
point
.
getCount
()
+
1
);
point
.
setSum
(
point
.
getSum
()
+
transaction
.
getDurationInMillis
());
point
.
setAvg
(
point
.
getSum
()
/
point
.
getCount
());
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
metric
=
report
.
findOrCreateMetric
(
name
);
Point
point
=
metric
.
findOrCreatePoint
(
min
);
point
.
setCount
(
point
.
getCount
()
+
1
);
point
.
setSum
(
point
.
getSum
()
+
transaction
.
getDurationInMillis
());
point
.
setAvg
(
point
.
getSum
()
/
point
.
getCount
());
Object
data
=
transaction
.
getData
();
if
(
data
!=
null
)
{
String
channel
=
parseValue
(
CHANNEL
,
(
String
)
data
);
if
(
channel
!=
null
)
{
updateChannel
(
min
,
metric
,
channel
,
transaction
.
getDurationInMillis
());
String
childKey
=
config
.
getClassifications
();
if
(
childKey
!=
null
&&
childKey
.
length
()
>
0
)
{
Object
data
=
transaction
.
getData
();
if
(
data
!=
null
)
{
String
channel
=
parseValue
(
childKey
,
(
String
)
data
);
if
(
channel
!=
null
)
{
updateMetricChild
(
min
,
metric
,
childKey
,
channel
,
transaction
.
getDurationInMillis
());
}
}
}
}
}
}
private
void
updateChannel
(
int
min
,
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
metric
,
String
channel
,
double
value
)
{
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
detail
=
metric
.
findOrCreateMetric
(
CHANNEL
+
"="
+
channel
);
private
void
updateMetricChild
(
int
min
,
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
metric
,
String
childKey
,
String
childValue
,
double
value
)
{
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
detail
=
metric
.
findOrCreateMetric
(
childKey
+
"="
+
childValue
);
Point
channelPoint
=
detail
.
findOrCreatePoint
(
min
);
...
...
@@ -187,12 +174,20 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
private
int
processMetric
(
String
group
,
MetricReport
report
,
MessageTree
tree
,
Metric
metric
)
{
String
name
=
metric
.
getName
();
Map
<
String
,
String
>
metrics
=
s_metric
.
get
(
group
);
String
key
=
metrics
.
get
(
name
);
String
domain
=
tree
.
getDomain
(
);
List
<
BusinessConfig
>
configs
=
m_configManager
.
getMetricConfigs
(
domain
);
if
(
key
!=
null
)
{
BusinessConfig
config
=
null
;
for
(
BusinessConfig
c
:
configs
)
{
if
(
c
.
getMainKey
().
equals
(
name
))
{
config
=
c
;
break
;
}
}
if
(
config
!=
null
)
{
String
data
=
(
String
)
metric
.
getData
();
String
valueStr
=
parseValue
(
key
,
data
);
String
valueStr
=
parseValue
(
config
.
getTarget
()
,
data
);
if
(
valueStr
!=
null
)
{
double
value
=
Double
.
parseDouble
(
valueStr
);
...
...
@@ -206,9 +201,14 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
point
.
setSum
(
point
.
getSum
()
+
value
);
point
.
setAvg
(
point
.
getSum
()
/
point
.
getCount
());
String
channel
=
parseValue
(
"channel"
,
data
);
if
(
channel
!=
null
)
{
updateChannel
(
min
,
temp
,
channel
,
value
);
String
childKey
=
config
.
getClassifications
();
if
(
childKey
!=
null
&&
childKey
.
length
()
>
0
)
{
if
(
data
!=
null
)
{
String
childValue
=
parseValue
(
childKey
,
data
);
if
(
childValue
!=
null
)
{
updateMetricChild
(
min
,
temp
,
childKey
,
childValue
,
value
);
}
}
}
}
}
...
...
@@ -315,7 +315,6 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
r
.
setPeriod
(
period
);
r
.
setIp
(
ip
);
r
.
setType
(
binary
);
// r.setBinaryContent(DefaultNativeBuilder.build(report));
r
.
setContent
(
DefaultNativeBuilder
.
build
(
report
));
r
.
setCreationDate
(
new
Date
());
...
...
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/build/ComponentsConfigurator.java
浏览文件 @
8b08e8d6
...
...
@@ -16,6 +16,7 @@ import com.dianping.cat.configuration.ServerConfigManager;
import
com.dianping.cat.consumer.CatConsumerAdvancedModule
;
import
com.dianping.cat.consumer.DomainManager
;
import
com.dianping.cat.consumer.MessageAnalyzer
;
import
com.dianping.cat.consumer.advanced.BussinessConfigManager
;
import
com.dianping.cat.consumer.advanced.CrossAnalyzer
;
import
com.dianping.cat.consumer.advanced.DatabaseAnalyzer
;
import
com.dianping.cat.consumer.advanced.DatabaseParser
;
...
...
@@ -31,29 +32,31 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
public
List
<
Component
>
defineComponents
()
{
List
<
Component
>
all
=
new
ArrayList
<
Component
>();
all
.
add
(
C
(
BussinessConfigManager
.
class
));
all
.
add
(
C
(
DomainManager
.
class
,
DomainManager
.
class
).
req
(
ServerConfigManager
.
class
,
HostinfoDao
.
class
));
all
.
add
(
C
(
SqlParseManager
.
class
).
req
(
SqltableDao
.
class
));
all
.
add
(
C
(
DatabaseParser
.
class
));
all
.
add
(
C
(
MessageAnalyzer
.
class
,
CrossAnalyzer
.
ID
,
CrossAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
ReportDao
.
class
));
all
.
add
(
C
(
MessageAnalyzer
.
class
,
DatabaseAnalyzer
.
ID
,
DatabaseAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
SqlParseManager
.
class
,
DatabaseParser
.
class
));
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
SqlParseManager
.
class
,
DatabaseParser
.
class
));
all
.
add
(
C
(
MessageAnalyzer
.
class
,
SqlAnalyzer
.
ID
,
SqlAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
SqlParseManager
.
class
,
DatabaseParser
.
class
));
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
SqlParseManager
.
class
,
DatabaseParser
.
class
));
all
.
add
(
C
(
MessageAnalyzer
.
class
,
MatrixAnalyzer
.
ID
,
MatrixAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
ReportDao
.
class
));
all
.
add
(
C
(
MessageAnalyzer
.
class
,
DependencyAnalyzer
.
ID
,
DependencyAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
DomainManager
.
class
,
DatabaseParser
.
class
));
.
req
(
BucketManager
.
class
,
ReportDao
.
class
,
DomainManager
.
class
,
DatabaseParser
.
class
));
all
.
add
(
C
(
MessageAnalyzer
.
class
,
MetricAnalyzer
.
ID
,
MetricAnalyzer
.
class
).
is
(
PER_LOOKUP
)
//
.
req
(
BucketManager
.
class
,
BusinessReportDao
.
class
));
.
req
(
BucketManager
.
class
,
BusinessReportDao
.
class
,
BussinessConfigManager
.
class
));
all
.
add
(
C
(
Module
.
class
,
CatConsumerAdvancedModule
.
ID
,
CatConsumerAdvancedModule
.
class
));
...
...
cat-consumer-advanced/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
8b08e8d6
<plexus>
<components>
<component>
<role>
com.dianping.cat.consumer.advanced.BussinessConfigManager
</role>
<implementation>
com.dianping.cat.consumer.advanced.BussinessConfigManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.consumer.DomainManager
</role>
<implementation>
com.dianping.cat.consumer.DomainManager
</implementation>
...
...
@@ -125,6 +129,9 @@
<requirement>
<role>
com.dainping.cat.consumer.advanced.dal.BusinessReportDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.advanced.BussinessConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
浏览文件 @
8b08e8d6
...
...
@@ -11,10 +11,10 @@ import org.unidal.web.mvc.annotation.InboundActionMeta;
import
org.unidal.web.mvc.annotation.OutboundActionMeta
;
import
org.unidal.web.mvc.annotation.PayloadMeta
;
import
com.dianping.cat.consumer.advanced.BussinessConfigManager
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.report.ReportPage
;
import
com.dianping.cat.report.page.PayloadNormalizer
;
import
com.dianping.cat.report.page.metric.MetricConfig.MetricFlag
;
import
com.dianping.cat.report.page.model.spi.ModelRequest
;
import
com.dianping.cat.report.page.model.spi.ModelResponse
;
import
com.dianping.cat.report.page.model.spi.ModelService
;
...
...
@@ -29,25 +29,10 @@ public class Handler implements PageHandler<Context> {
@Inject
private
PayloadNormalizer
m_normalizePayload
;
private
static
final
String
TUAN
=
"TuanGou"
;
@Inject
private
BussinessConfigManager
m_configManager
;
private
MetricConfig
buildTuanGouMetricConfig
(
String
channel
)
{
MetricConfig
config
=
new
MetricConfig
();
MetricFlag
indexUrl
=
new
MetricFlag
(
"/index"
,
channel
,
1
,
true
,
false
,
false
,
MetricTitle
.
INDEX
);
MetricFlag
detailUrl
=
new
MetricFlag
(
"/detail"
,
channel
,
2
,
true
,
false
,
false
,
MetricTitle
.
DETAIL
);
MetricFlag
payUrl
=
new
MetricFlag
(
"/order/submitOrder"
,
channel
,
3
,
true
,
false
,
false
,
MetricTitle
.
PAY
);
MetricFlag
orderKey
=
new
MetricFlag
(
"order"
,
channel
,
4
,
false
,
true
,
false
,
MetricTitle
.
ORDER
);
MetricFlag
totalKey
=
new
MetricFlag
(
"payment.success"
,
channel
,
5
,
false
,
true
,
false
,
MetricTitle
.
SUCCESS
);
// MetricFlag sumKey = new MetricFlag("payment.pending", 5, false, true, false);
config
.
put
(
indexUrl
);
config
.
put
(
detailUrl
);
config
.
put
(
payUrl
);
config
.
put
(
orderKey
);
config
.
put
(
totalKey
);
return
config
;
}
private
static
final
String
TUAN
=
"TuanGou"
;
private
MetricReport
getReport
(
Payload
payload
)
{
String
group
=
payload
.
getGroup
();
...
...
@@ -80,6 +65,7 @@ public class Handler implements PageHandler<Context> {
public
void
handleOutbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
Model
model
=
new
Model
(
ctx
);
Payload
payload
=
ctx
.
getPayload
();
normalize
(
model
,
payload
);
MetricReport
report
=
getReport
(
payload
);
...
...
@@ -90,36 +76,29 @@ public class Handler implements PageHandler<Context> {
if
(
startTime
==
null
)
{
startTime
=
payload
.
getHistoryStartDate
();
}
MetricDisplay
display
=
new
MetricDisplay
(
buildTuanGouMetricConfig
(
channel
),
channel
,
startTime
);
MetricDisplay
display
=
new
MetricDisplay
(
m_configManager
.
getConfigs
(
payload
.
getGroup
()
),
channel
,
startTime
);
display
.
visitMetricReport
(
report
);
model
.
setDisplay
(
display
);
model
.
setChannels
(
display
.
getAllCh
annel
());
model
.
setChannels
(
display
.
getAllCh
ildKeyValues
());
//TODO
model
.
setReport
(
report
);
model
.
setGroups
(
m_configManager
.
getGroups
());
model
.
setChildKey
(
display
.
getChildKey
());
model
.
setChildKeyValues
(
display
.
getAllChildKeyValues
());
}
m_jspViewer
.
view
(
ctx
,
model
);
}
private
void
normalize
(
Model
model
,
Payload
payload
)
{
payload
.
setGroup
(
TUAN
);
model
.
setGroup
(
payload
.
getGroup
());
model
.
setChannel
(
payload
.
getChannel
());
model
.
setPage
(
ReportPage
.
METRIC
);
m_normalizePayload
.
normalize
(
model
,
payload
);
}
public
class
MetricTitle
{
public
static
final
String
INDEX
=
"团购首页(次)"
;
public
static
final
String
DETAIL
=
"团购详情(次)"
;
public
static
final
String
PAY
=
"支付页面(次)"
;
public
static
final
String
ORDER
=
"订单创建数量(个)"
;
public
static
final
String
SUCCESS
=
"支付金额(元)"
;
String
group
=
payload
.
getGroup
();
if
(
group
==
null
||
group
.
length
()
==
0
)
{
payload
.
setGroup
(
TUAN
);
}
model
.
setGroup
(
payload
.
getGroup
());
}
}
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricConfig.java
已删除
100644 → 0
浏览文件 @
ea9c917c
package
com.dianping.cat.report.page.metric
;
import
java.util.Collection
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
public
class
MetricConfig
{
private
Map
<
String
,
MetricFlag
>
m_flags
=
new
LinkedHashMap
<
String
,
MetricFlag
>();
public
MetricFlag
get
(
String
key
)
{
return
m_flags
.
get
(
key
);
}
public
Collection
<
MetricFlag
>
getFlags
()
{
return
m_flags
.
values
();
}
public
void
put
(
MetricFlag
flag
)
{
m_flags
.
put
(
flag
.
getKey
(),
flag
);
}
public
static
class
MetricFlag
{
private
String
m_key
;
private
String
m_key2
;
private
int
m_index
;
private
boolean
m_showCount
;
private
boolean
m_showSum
;
private
boolean
m_showAvg
;
private
String
m_title
;
public
MetricFlag
(
String
key
,
String
key2
,
int
index
,
boolean
showCount
,
boolean
showSum
,
boolean
showAvg
,
String
title
)
{
m_key
=
key
;
m_key2
=
key
;
m_index
=
index
;
m_showCount
=
showCount
;
m_showSum
=
showSum
;
m_showAvg
=
showAvg
;
m_title
=
title
;
}
public
int
getIndex
()
{
return
m_index
;
}
public
String
getKey
()
{
return
m_key
;
}
public
String
getKey2
()
{
return
m_key2
;
}
public
String
getTitle
()
{
return
m_title
;
}
public
boolean
isShowAvg
()
{
return
m_showAvg
;
}
public
boolean
isShowCount
()
{
return
m_showCount
;
}
public
boolean
isShowSum
()
{
return
m_showSum
;
}
public
void
setKey2
(
String
key2
)
{
m_key2
=
key2
;
}
public
void
setTitle
(
String
title
)
{
m_title
=
title
;
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricDisplay.java
浏览文件 @
8b08e8d6
...
...
@@ -12,12 +12,12 @@ import java.util.TreeSet;
import
org.apache.commons.lang.StringUtils
;
import
com.dianping.cat.consumer.advanced.BussinessConfigManager.BusinessConfig
;
import
com.dianping.cat.consumer.metric.model.entity.Metric
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.consumer.metric.model.entity.Point
;
import
com.dianping.cat.consumer.metric.model.transform.BaseVisitor
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.report.page.metric.MetricConfig.MetricFlag
;
import
com.google.gson.Gson
;
public
class
MetricDisplay
extends
BaseVisitor
{
...
...
@@ -26,34 +26,36 @@ public class MetricDisplay extends BaseVisitor {
private
String
m_key
;
private
String
m_c
hannel
;
private
String
m_c
lassificationValue
;
private
Date
m_start
;
private
MetricConfig
m_config
;
private
String
m_classificationKey
;
private
S
tring
prefix
=
"channel="
;
private
S
et
<
String
>
m_allChildKeyValues
=
new
TreeSet
<
String
>()
;
private
Set
<
String
>
m_allChannel
=
new
TreeSet
<
String
>();
public
MetricDisplay
(
MetricConfig
metricConfig
,
String
channel
,
Date
start
)
{
m_config
=
metricConfig
;
public
MetricDisplay
(
List
<
BusinessConfig
>
configs
,
String
classificationValue
,
Date
start
)
{
m_start
=
start
;
m_c
hannel
=
channel
;
m_c
lassificationValue
=
classificationValue
;
for
(
MetricFlag
flag
:
m_config
.
getFlags
()
)
{
for
(
BusinessConfig
flag
:
configs
)
{
String
title
=
flag
.
getTitle
();
String
classifications
=
flag
.
getClassifications
();
if
(
classifications
!=
null
&&
classifications
.
length
()
>
0
)
{
m_classificationKey
=
classifications
;
}
if
(
flag
.
isShowSum
())
{
String
key
=
flag
.
getKey
()
+
":sum"
;
m_metrics
.
put
(
key
,
new
GraphItem
(
m_start
,
title
,
flag
.
get
Key
()));
String
key
=
flag
.
get
Main
Key
()
+
":sum"
;
m_metrics
.
put
(
key
,
new
GraphItem
(
m_start
,
title
+
BusinessConfig
.
Suffix_SUM
,
flag
.
getMain
Key
()));
}
if
(
flag
.
isShowCount
())
{
String
key
=
flag
.
getKey
()
+
":count"
;
m_metrics
.
put
(
key
,
new
GraphItem
(
m_start
,
title
,
flag
.
get
Key
()));
String
key
=
flag
.
get
Main
Key
()
+
":count"
;
m_metrics
.
put
(
key
,
new
GraphItem
(
m_start
,
title
+
BusinessConfig
.
Suffix_COUNT
,
flag
.
getMain
Key
()));
}
if
(
flag
.
isShowAvg
())
{
String
key
=
flag
.
getKey
()
+
":avg"
;
m_metrics
.
put
(
key
,
new
GraphItem
(
m_start
,
title
,
flag
.
get
Key
()));
String
key
=
flag
.
get
Main
Key
()
+
":avg"
;
m_metrics
.
put
(
key
,
new
GraphItem
(
m_start
,
title
+
BusinessConfig
.
Suffix_AVG
,
flag
.
getMain
Key
()));
}
}
}
...
...
@@ -81,8 +83,12 @@ public class MetricDisplay extends BaseVisitor {
}
}
public
Set
<
String
>
getAllChannel
()
{
return
m_allChannel
;
public
Set
<
String
>
getAllChildKeyValues
()
{
return
m_allChildKeyValues
;
}
public
String
getChildKey
()
{
return
m_classificationKey
;
}
public
List
<
GraphItem
>
getGroups
()
{
...
...
@@ -97,15 +103,13 @@ public class MetricDisplay extends BaseVisitor {
if
(
metrics
!=
null
)
{
Set
<
String
>
keySet
=
metrics
.
keySet
();
for
(
String
temp
:
keySet
)
{
if
(
temp
.
startsWith
(
prefix
))
{
m_allChannel
.
add
(
temp
.
substring
(
prefix
.
length
()));
}
m_allChildKeyValues
.
add
(
temp
.
substring
(
temp
.
indexOf
(
'='
)
+
1
));
}
}
if
(
StringUtils
.
isEmpty
(
m_c
hannel
))
{
if
(
StringUtils
.
isEmpty
(
m_c
lassificationValue
))
{
buildGraphItem
(
metric
.
getPoints
().
values
());
}
else
{
Metric
m
=
metrics
.
get
(
prefix
+
m_channel
);
Metric
m
=
metrics
.
get
(
m_classificationKey
+
'='
+
m_classificationValue
);
if
(
m
!=
null
)
{
buildGraphItem
(
m
.
getPoints
().
values
());
...
...
cat-home/src/main/java/com/dianping/cat/report/page/metric/Model.java
浏览文件 @
8b08e8d6
...
...
@@ -19,6 +19,12 @@ public class Model extends AbstractReportModel<Action, Context> {
private
Set
<
String
>
m_channels
;
private
Set
<
String
>
m_groups
;
private
Set
<
String
>
m_childKeyValues
;
private
String
m_childKey
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
...
...
@@ -78,4 +84,28 @@ public class Model extends AbstractReportModel<Action, Context> {
m_report
=
report
;
}
public
void
setGroups
(
Set
<
String
>
groups
)
{
m_groups
=
groups
;
}
public
Set
<
String
>
getGroups
()
{
return
m_groups
;
}
public
void
setChildKeyValues
(
Set
<
String
>
childKeys
)
{
m_childKeyValues
=
childKeys
;
}
public
Set
<
String
>
getChildKeyValues
()
{
return
m_childKeyValues
;
}
public
String
getChildKey
()
{
return
m_childKey
;
}
public
void
setChildKey
(
String
childKey
)
{
m_childKey
=
childKey
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/metric/Payload.java
浏览文件 @
8b08e8d6
...
...
@@ -12,7 +12,7 @@ public class Payload extends AbstractReportPayload<Action> {
@FieldMeta
(
"op"
)
private
Action
m_action
;
@FieldMeta
(
"
o
p"
)
@FieldMeta
(
"
grou
p"
)
private
String
m_group
;
@FieldMeta
(
"channel"
)
...
...
cat-home/src/main/java/com/dianping/cat/report/page/transaction/TransactionMergeManager.java
浏览文件 @
8b08e8d6
...
...
@@ -32,3 +32,4 @@ public class TransactionMergeManager {
}
}
cat-home/src/main/java/com/dianping/cat/report/task/spi/ReportFacade.java
浏览文件 @
8b08e8d6
...
...
@@ -88,19 +88,24 @@ public class ReportFacade implements LogEnabled, Initializable {
m_logger
.
info
(
"no report builder for type:"
+
" "
+
reportName
);
return
false
;
}
else
{
boolean
result
=
false
;
if
(
type
==
TYPE_DAILY
)
{
re
turn
reportBuilder
.
buildDailyReport
(
reportName
,
reportDomain
,
reportPeriod
);
re
sult
=
reportBuilder
.
buildDailyReport
(
reportName
,
reportDomain
,
reportPeriod
);
}
else
if
(
type
==
TYPE_HOUR
)
{
re
turn
reportBuilder
.
buildHourReport
(
reportName
,
reportDomain
,
reportPeriod
);
re
sult
=
reportBuilder
.
buildHourReport
(
reportName
,
reportDomain
,
reportPeriod
);
}
else
if
(
type
==
TYPE_WEEK
)
{
re
turn
reportBuilder
.
buildWeeklyReport
(
reportName
,
reportDomain
,
reportPeriod
);
re
sult
=
reportBuilder
.
buildWeeklyReport
(
reportName
,
reportDomain
,
reportPeriod
);
}
else
if
(
type
==
TYPE_MONTH
)
{
return
reportBuilder
.
buildMonthReport
(
reportName
,
reportDomain
,
reportPeriod
);
result
=
reportBuilder
.
buildMonthReport
(
reportName
,
reportDomain
,
reportPeriod
);
}
if
(
result
)
{
return
result
;
}
else
{
m_logger
.
error
(
task
.
toString
());
}
}
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Flowing is error stack trace:"
);
e
.
printStackTrace
();
m_logger
.
error
(
"Error when building report,"
+
e
.
getMessage
(),
e
);
Cat
.
logError
(
e
);
return
false
;
...
...
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
浏览文件 @
8b08e8d6
...
...
@@ -41,13 +41,13 @@ public class NavigationBar {
ReportPage
.
SQL
,
ReportPage
.
DATABASE
,
ReportPage
.
MATRIX
,
//
ReportPage.DATABASE,
//
//
ReportPage.MATRIX,
ReportPage
.
DEPENDENCY
,
ReportPage
.
HEALTH
,
//
ReportPage.HEALTH,
ReportPage
.
TOP
,
...
...
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
8b08e8d6
...
...
@@ -2445,6 +2445,9 @@
<requirement>
<role>
com.dianping.cat.report.page.PayloadNormalizer
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.consumer.advanced.BussinessConfigManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -2456,6 +2459,10 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.consumer.advanced.BussinessConfigManager
</role>
<implementation>
com.dianping.cat.consumer.advanced.BussinessConfigManager
</implementation>
</component>
<component>
<role>
com.dianping.cat.report.page.jsError.Handler
</role>
<implementation>
com.dianping.cat.report.page.jsError.Handler
</implementation>
...
...
cat-home/src/main/webapp/jsp/report/metric.jsp
浏览文件 @
8b08e8d6
...
...
@@ -15,16 +15,7 @@
<res:useJs
value=
"
${
res
.
js
.
local
[
'bootstrap.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'flotr2_js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'metric.js'
]
}
"
target=
"head-js"
/>
<style
type=
"text/css"
>
.graph
{
width
:
380px
;
height
:
200px
;
margin
:
4px
auto
;
}
.row-fluid
.span2
{
width
:
12%
;
}
</style>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
<c:forEach
var=
"item"
items=
"
${
model
.
display
.
groups
}
"
varStatus=
"status"
>
...
...
@@ -32,12 +23,16 @@
graph
(
document
.
getElementById
(
'
${item.title}
'
),
data
);
</c:forEach>
var
id
=
"
${model.channel}
"
;
/*
var id = "${model.channel}";
if (id == '') {
$('#allChannel').addClass("active");
} else {
$('#' + id).addClass("active");
}
} */
var
group
=
'
${model.group}
'
;
$
(
'
#
'
+
group
).
addClass
(
"
active
"
);
var
childKey
=
'
${model.channel}
'
;
$
(
'
#
'
+
childKey
).
addClass
(
"
active
"
);
});
</script>
<div
class=
"report"
>
...
...
@@ -58,11 +53,16 @@
<div
class=
"span2"
>
<div
class=
"well sidebar-nav"
>
<ul
class=
"nav nav-list"
>
<li
id=
"allChannel"
><a
href=
"?date=${model.date}&group=${model.group}"
><strong>
团购ALL
</strong></a></li>
<c:forEach
var=
"item"
items=
"
${
model
.
groups
}
"
varStatus=
"status"
>
<li
class=
'nav-header'
id=
"${item}"
><a
href=
"?date=${model.date}&group=${item}"
><strong>
${item}
</strong></a></li>
<c:if
test=
"
${
model
.
group
eq
item
}
"
>
<c:forEach
var=
"item"
items=
"
${
model
.
childKeyValues
}
"
varStatus=
"status"
>
<li
id=
"${item}"
><a
href=
"?date=${model.date}&group=${model.group}&${model.childKey}=${item}"
>
${item}
</a></li>
</c:forEach>
</c:if>
</c:forEach>
<li
>
</li>
<c:forEach
var=
"item"
items=
"
${
model
.
channels
}
"
varStatus=
"status"
>
<li
id=
"${item}"
><a
href=
"?date=${model.date}&group=${model.group}&channel=${item}"
>
${item}
</a></li>
</c:forEach>
</ul>
</div>
<!--/.well -->
</div>
<!--/span-->
...
...
@@ -77,4 +77,27 @@
</tr>
</table>
</div>
</a:body>
\ No newline at end of file
</a:body>
<style
type=
"text/css"
>
.graph
{
width
:
380px
;
height
:
200px
;
margin
:
4px
auto
;
}
.row-fluid
.span2
{
width
:
12%
;
}
.well
{
padding
:
10px
10px
10px
19
p
;
}
.nav-list
li
a
{
padding
:
2px
15px
;
}
.nav
li
+
.nav-header
{
margin-top
:
2px
;
}
.nav-header
{
padding
:
5px
3px
;
}
</style>
cat-home/src/test/java/com/dianping/cat/demo/TestBusinessMessage.java
浏览文件 @
8b08e8d6
...
...
@@ -5,34 +5,96 @@ import org.junit.Test;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.internal.DefaultMessageTree
;
public
class
TestBusinessMessage
{
private
static
final
String
TuanGou
=
"TuanGouWeb"
;
private
static
final
String
PayOrder
=
"PayOrder"
;
@Test
public
void
test
()
throws
Exception
{
while
(
true
)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/index"
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
Cat
.
logEvent
(
"RemoteLink"
,
"sina"
,
Event
.
SUCCESS
,
"http://sina.com.cn/"
);
t
.
addData
(
"channel=channel"
+
i
%
5
);
DefaultMessageTree
tree
=
(
DefaultMessageTree
)
Cat
.
getManager
().
getThreadLocalMessageTree
();
tree
.
setDomain
(
TuanGou
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
900
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/detail"
);
Cat
.
logMetric
(
"payment.pending"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
DefaultMessageTree
tree
=
(
DefaultMessageTree
)
Cat
.
getManager
().
getThreadLocalMessageTree
();
tree
.
setDomain
(
TuanGou
);
t
.
addData
(
"channel=channel"
+
i
%
5
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
500
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/order/submitOrder"
);
Cat
.
logMetric
(
"payment.success"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
DefaultMessageTree
tree
=
(
DefaultMessageTree
)
Cat
.
getManager
().
getThreadLocalMessageTree
();
tree
.
setDomain
(
PayOrder
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
1
,
"channel"
,
"channel"
+
i
%
5
);
Cat
.
logMetric
(
"payment.pending"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
Cat
.
logMetric
(
"payment.success"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
t
.
addData
(
"channel=channel"
+
i
%
5
);
t
.
complete
();
}
Thread
.
sleep
(
10000
);
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"t"
);
Cat
.
logEvent
(
"RemoteLink"
,
"sina"
,
Event
.
SUCCESS
,
"http://sina.com.cn/"
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
900
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"e"
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
500
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"home"
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
1
,
"channel"
,
"channel"
+
i
%
5
);
Cat
.
logMetric
(
"payment.pending"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
Cat
.
logMetric
(
"payment.success"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
t
.
complete
();
}
Thread
.
sleep
(
1000
);
}
}
@Test
public
void
test2
()
throws
Exception
{
while
(
true
)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/index"
);
Cat
.
logEvent
(
"RemoteLink"
,
"sina"
,
Event
.
SUCCESS
,
"http://sina.com.cn/"
);
t
.
addData
(
"channel=channel"
+
i
%
5
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
900
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/detail"
);
t
.
addData
(
"channel=channel"
+
i
%
5
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
500
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/order/submitOrder"
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
1
,
"channel"
,
"channel"
+
i
%
5
);
Cat
.
logMetric
(
"payment.pending"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
Cat
.
logMetric
(
"payment.success"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
t
.
addData
(
"channel=channel"
+
i
%
5
);
t
.
complete
();
}
Thread
.
sleep
(
1000
);
break
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录