Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
b78e3abb
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,发现更多精彩内容 >>
提交
b78e3abb
编写于
4月 24, 2013
作者:
Y
yong.you
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the channel display and fix channel bug
上级
4caa0277
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
89 addition
and
45 deletion
+89
-45
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
...va/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
+24
-20
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
...ain/java/com/dianping/cat/report/page/metric/Handler.java
+2
-1
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricDisplay.java
...va/com/dianping/cat/report/page/metric/MetricDisplay.java
+27
-3
cat-home/src/main/java/com/dianping/cat/report/page/metric/Model.java
.../main/java/com/dianping/cat/report/page/metric/Model.java
+16
-5
cat-home/src/main/webapp/js/metric.js
cat-home/src/main/webapp/js/metric.js
+3
-0
cat-home/src/main/webapp/jsp/report/metric.jsp
cat-home/src/main/webapp/jsp/report/metric.jsp
+11
-10
cat-home/src/test/java/com/dianping/cat/demo/TestBusinessMessage.java
.../test/java/com/dianping/cat/demo/TestBusinessMessage.java
+6
-6
未找到文件。
cat-consumer-advanced/src/main/java/com/dianping/cat/consumer/advanced/MetricAnalyzer.java
浏览文件 @
b78e3abb
...
...
@@ -166,16 +166,17 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
Object
data
=
transaction
.
getData
();
if
(
data
!=
null
)
{
double
value
=
parseValue
(
CHANNEL
,
(
String
)
data
);
if
(
value
>
0
)
{
updateChannel
(
min
,
metric
,
value
);
String
channel
=
parseValue
(
CHANNEL
,
(
String
)
data
);
if
(
channel
!=
null
)
{
updateChannel
(
min
,
metric
,
channel
,
transaction
.
getDurationInMillis
()
);
}
}
}
}
private
void
updateChannel
(
int
min
,
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
metric
,
double
value
)
{
com
.
dianping
.
cat
.
consumer
.
metric
.
model
.
entity
.
Metric
detail
=
metric
.
findOrCreateMetric
(
CHANNEL
+
"="
+
(
int
)
(
value
));
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
);
Point
channelPoint
=
detail
.
findOrCreatePoint
(
min
);
...
...
@@ -191,8 +192,10 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
if
(
key
!=
null
)
{
String
data
=
(
String
)
metric
.
getData
();
double
value
=
parseValue
(
key
,
data
);
String
valueStr
=
parseValue
(
key
,
data
);
if
(
valueStr
!=
null
)
{
double
value
=
Double
.
parseDouble
(
valueStr
);
long
current
=
metric
.
getTimestamp
()
/
1000
/
60
;
int
min
=
(
int
)
(
current
%
(
60
));
...
...
@@ -203,15 +206,16 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
point
.
setSum
(
point
.
getSum
()
+
value
);
point
.
setAvg
(
point
.
getSum
()
/
point
.
getCount
());
double
channel
=
parseValue
(
"channel"
,
data
);
if
(
channel
>
0
)
{
updateChannel
(
min
,
temp
,
channel
);
String
channel
=
parseValue
(
"channel"
,
data
);
if
(
channel
!=
null
)
{
updateChannel
(
min
,
temp
,
channel
,
value
);
}
}
}
return
0
;
}
public
double
parseValue
(
final
String
key
,
final
String
data
)
{
public
String
parseValue
(
final
String
key
,
final
String
data
)
{
int
len
=
data
==
null
?
0
:
data
.
length
();
int
keyLen
=
key
.
length
();
StringBuilder
name
=
new
StringBuilder
();
...
...
@@ -224,7 +228,7 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
switch
(
ch
)
{
case
'&'
:
if
(
name
.
length
()
==
keyLen
&&
name
.
toString
().
equals
(
key
))
{
return
Double
.
parseDouble
(
value
.
toString
()
);
return
value
.
toString
(
);
}
inName
=
true
;
...
...
@@ -249,10 +253,10 @@ public class MetricAnalyzer extends AbstractMessageAnalyzer<MetricReport> implem
}
if
(
name
.
length
()
==
keyLen
&&
name
.
toString
().
equals
(
key
))
{
return
Double
.
parseDouble
(
value
.
toString
()
);
return
value
.
toString
(
);
}
return
0
;
return
null
;
}
private
int
processTransaction
(
String
group
,
MetricReport
report
,
MessageTree
tree
,
Transaction
t
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/metric/Handler.java
浏览文件 @
b78e3abb
...
...
@@ -63,10 +63,11 @@ public class Handler implements PageHandler<Context> {
String
channel
=
payload
.
getChannel
();
if
(
report
!=
null
)
{
MetricDisplay
display
=
new
MetricDisplay
(
buildTuanGouMetricConfig
(
channel
),
channel
,
report
.
getStartTime
());
MetricDisplay
display
=
new
MetricDisplay
(
buildTuanGouMetricConfig
(
channel
),
channel
,
report
.
getStartTime
());
display
.
visitMetricReport
(
report
);
model
.
setDisplay
(
display
);
model
.
setChannels
(
display
.
getAllChannel
());
model
.
setReport
(
report
);
}
m_jspViewer
.
view
(
ctx
,
model
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/metric/MetricDisplay.java
浏览文件 @
b78e3abb
...
...
@@ -7,6 +7,8 @@ import java.util.Date;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -30,6 +32,14 @@ public class MetricDisplay extends BaseVisitor {
private
MetricConfig
m_config
;
private
String
prefix
=
"channel="
;
private
Set
<
String
>
m_allChannel
=
new
TreeSet
<
String
>();
public
Set
<
String
>
getAllChannel
()
{
return
m_allChannel
;
}
public
MetricDisplay
(
MetricConfig
metricConfig
,
String
channel
,
Date
start
)
{
m_config
=
metricConfig
;
m_start
=
start
;
...
...
@@ -60,11 +70,19 @@ public class MetricDisplay extends BaseVisitor {
public
void
visitMetric
(
Metric
metric
)
{
m_key
=
metric
.
getId
();
Map
<
String
,
Metric
>
metrics
=
metric
.
getMetrics
();
if
(
metrics
!=
null
)
{
Set
<
String
>
keySet
=
metrics
.
keySet
();
for
(
String
temp
:
keySet
)
{
if
(
temp
.
startsWith
(
prefix
))
{
m_allChannel
.
add
(
temp
.
substring
(
prefix
.
length
()));
}
}
}
if
(
StringUtils
.
isEmpty
(
m_channel
))
{
buildGraphItem
(
metric
.
getPoints
().
values
());
}
else
{
Map
<
String
,
Metric
>
metrics
=
metric
.
getMetrics
();
Metric
m
=
metrics
.
get
(
"channel="
+
m_channel
);
Metric
m
=
metrics
.
get
(
prefix
+
m_channel
);
if
(
m
!=
null
)
{
buildGraphItem
(
m
.
getPoints
().
values
());
...
...
@@ -113,12 +131,18 @@ public class MetricDisplay extends BaseVisitor {
private
String
key
;
private
double
[]
values
=
new
double
[
60
];
private
static
final
int
SIZE
=
60
;
private
double
[]
values
=
new
double
[
SIZE
];
public
GraphItem
(
Date
start
,
String
title
,
String
key
)
{
this
.
start
=
sdf
.
format
(
start
);
this
.
title
=
title
;
this
.
key
=
key
;
for
(
int
i
=
0
;
i
<
SIZE
;
i
++)
{
values
[
i
]
=
-
1
;
}
}
public
GraphItem
addSubTitle
(
String
title
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/metric/Model.java
浏览文件 @
b78e3abb
...
...
@@ -2,6 +2,7 @@ package com.dianping.cat.report.page.metric;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Set
;
import
com.dianping.cat.consumer.metric.model.entity.MetricReport
;
import
com.dianping.cat.report.page.AbstractReportModel
;
...
...
@@ -18,6 +19,8 @@ public class Model extends AbstractReportModel<Action, Context> {
private
String
m_channel
;
private
Set
<
String
>
m_channels
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
...
...
@@ -73,4 +76,12 @@ public class Model extends AbstractReportModel<Action, Context> {
m_group
=
group
;
}
public
Set
<
String
>
getChannels
()
{
return
m_channels
;
}
public
void
setChannels
(
Set
<
String
>
channels
)
{
m_channels
=
channels
;
}
}
cat-home/src/main/webapp/js/metric.js
浏览文件 @
b78e3abb
...
...
@@ -16,6 +16,9 @@ function graph(container, data) {
selection
:
{
mode
:
'
x
'
},
yaxis
:
{
min
:
0
},
HtmlText
:
false
,
title
:
data
.
title
};
...
...
cat-home/src/main/webapp/jsp/report/metric.jsp
浏览文件 @
b78e3abb
...
...
@@ -15,7 +15,7 @@
<res:useCss
value=
'
${
res
.
css
.
local
.
report_css
}
'
target=
"head-css"
/>
<res:useCss
value=
'
${
res
.
css
.
local
.
table_css
}
'
target=
"head-css"
/>
<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
[
'flotr2_js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'metric.js'
]
}
"
target=
"head-js"
/>
<style
type=
"text/css"
>
.graph
{
...
...
@@ -34,10 +34,13 @@
graph
(
document
.
getElementById
(
'
${item.title}
'
),
data
);
</c:forEach>
var
id
=
"
channel
"
+
'
${model.channel}
'
;
$
(
'
#
'
+
id
).
addClass
(
"
active
"
);
var
id
=
"
${model.channel}
"
;
if
(
id
==
''
)
{
$
(
'
#allChannel
'
).
addClass
(
"
active
"
);
}
else
{
$
(
'
#
'
+
id
).
addClass
(
"
active
"
);
}
});
</script>
<div
class=
"report"
>
<table
class=
"header"
>
...
...
@@ -57,13 +60,11 @@
<div
class=
"span2"
>
<div
class=
"well sidebar-nav"
>
<ul
class=
"nav nav-list"
>
<li
id=
"
c
hannel"
><a
href=
"?date=${model.date}&group=${model.group}"
><strong>
团购ALL
</strong></a></li>
<li
id=
"
allC
hannel"
><a
href=
"?date=${model.date}&group=${model.group}"
><strong>
团购ALL
</strong></a></li>
<li
>
</li>
<li
id=
"channel1"
><a
href=
"?date=${model.date}&group=${model.group}&channel=1"
>
渠道:搜索引擎
</a></li>
<li
id=
"channel2"
><a
href=
"?date=${model.date}&group=${model.group}&channel=2"
>
渠道:微博推广
</a></li>
<li
id=
"channel3"
><a
href=
"?date=${model.date}&group=${model.group}&channel=3"
>
渠道:腾讯推广
</a></li>
<li
id=
"channel4"
><a
href=
"?date=${model.date}&group=${model.group}&channel=4"
>
渠道:内部引流
</a></li>
<li
id=
"channel5"
><a
href=
"?date=${model.date}&group=${model.group}&channel=5"
>
渠道:团800
</a></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-->
...
...
cat-home/src/test/java/com/dianping/cat/demo/TestBusinessMessage.java
浏览文件 @
b78e3abb
...
...
@@ -13,20 +13,20 @@ public class TestBusinessMessage {
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/index"
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
i
,
"channel"
,
i
%
5
);
t
.
addData
(
"channel="
+
i
%
5
);
Cat
.
logMetric
(
"order"
,
"quantity"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
t
.
addData
(
"channel=
channel
"
+
i
%
5
);
t
.
complete
();
}
for
(
int
i
=
0
;
i
<
900
;
i
++)
{
Transaction
t
=
Cat
.
newTransaction
(
"URL"
,
"/detail"
);
Cat
.
logMetric
(
"payment.pending"
,
"amount"
,
i
,
"channel"
,
i
%
5
);
t
.
addData
(
"channel="
+
i
%
5
);
Cat
.
logMetric
(
"payment.pending"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
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"
,
i
%
5
);
t
.
addData
(
"channel="
+
i
%
5
);
Cat
.
logMetric
(
"payment.success"
,
"amount"
,
i
,
"channel"
,
"channel"
+
i
%
5
);
t
.
addData
(
"channel=
channel
"
+
i
%
5
);
t
.
complete
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录