Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
6295af53
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6295af53
编写于
7月 30, 2018
作者:
歪
歪脖大肚子Q
提交者:
wu-sheng
7月 30, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add gzip support (#1506)
* add gzip support
上级
454611db
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
19 deletion
+27
-19
apm-collector/apm-collector-thirdparty-receiver/receiver-zipkin/receiver-zipkin-provider/src/main/java/org/apache/skywalking/apm/collector/receiver/zipkin/provider/handler/SpanProcessor.java
...ector/receiver/zipkin/provider/handler/SpanProcessor.java
+23
-18
apm-collector/apm-collector-thirdparty-receiver/receiver-zipkin/receiver-zipkin-provider/src/main/java/org/apache/skywalking/apm/collector/receiver/zipkin/provider/transform/SegmentBuilder.java
...or/receiver/zipkin/provider/transform/SegmentBuilder.java
+4
-1
未找到文件。
apm-collector/apm-collector-thirdparty-receiver/receiver-zipkin/receiver-zipkin-provider/src/main/java/org/apache/skywalking/apm/collector/receiver/zipkin/provider/handler/SpanProcessor.java
浏览文件 @
6295af53
...
...
@@ -21,36 +21,28 @@ package org.apache.skywalking.apm.collector.receiver.zipkin.provider.handler;
import
org.apache.skywalking.apm.collector.receiver.zipkin.provider.RegisterServices
;
import
org.apache.skywalking.apm.collector.receiver.zipkin.provider.ZipkinReceiverConfig
;
import
org.apache.skywalking.apm.collector.receiver.zipkin.provider.cache.CacheFactory
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
zipkin2.Span
;
import
zipkin2.codec.SpanBytesDecoder
;
import
javax.servlet.ServletInputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.zip.GZIPInputStream
;
public
class
SpanProcessor
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SpanProcessor
.
class
);
void
convert
(
ZipkinReceiverConfig
config
,
SpanBytesDecoder
decoder
,
HttpServletRequest
request
,
RegisterServices
registerServices
)
throws
IOException
{
int
len
=
request
.
getContentLength
();
ServletInputStream
iii
=
request
.
getInputStream
();
byte
[]
buffer
=
new
byte
[
len
];
int
readCntTotal
=
0
;
InputStream
inputStream
=
getInputStream
(
request
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
byte
[]
buffer
=
new
byte
[
2048
];
int
readCntOnce
;
while
(
readCntTotal
<
len
)
{
readCntOnce
=
iii
.
read
(
buffer
,
readCntTotal
,
len
-
readCntTotal
);
if
(
readCntOnce
<=
0
)
{
logger
.
error
(
"Receive spans data failed."
);
throw
new
IOException
();
}
readCntTotal
+=
readCntOnce
;
while
((
readCntOnce
=
inputStream
.
read
(
buffer
))
>=
0
)
{
out
.
write
(
buffer
,
0
,
readCntOnce
);
}
List
<
Span
>
spanList
=
decoder
.
decodeList
(
buffer
);
List
<
Span
>
spanList
=
decoder
.
decodeList
(
out
.
toByteArray
()
);
spanList
.
forEach
(
span
->
{
// In Zipkin, the local service name represents the application owner.
...
...
@@ -65,4 +57,17 @@ public class SpanProcessor {
CacheFactory
.
INSTANCE
.
get
(
config
).
addSpan
(
span
);
});
}
private
InputStream
getInputStream
(
HttpServletRequest
request
)
throws
IOException
{
InputStream
requestInStream
;
String
headEncoding
=
request
.
getHeader
(
"accept-encoding"
);
if
(
headEncoding
!=
null
&&
(
headEncoding
.
indexOf
(
"gzip"
)
!=
-
1
))
{
requestInStream
=
new
GZIPInputStream
(
request
.
getInputStream
());
}
else
{
requestInStream
=
request
.
getInputStream
();
}
return
requestInStream
;
}
}
apm-collector/apm-collector-thirdparty-receiver/receiver-zipkin/receiver-zipkin-provider/src/main/java/org/apache/skywalking/apm/collector/receiver/zipkin/provider/transform/SegmentBuilder.java
浏览文件 @
6295af53
...
...
@@ -183,7 +183,10 @@ public class SegmentBuilder {
}
// microseconds in Zipkin -> milliseconds in SkyWalking
long
startTime
=
span
.
timestamp
()
/
1000
;
long
duration
=
span
.
duration
()
/
1000
;
// Some implement of zipkin client not include duration field in its report
// package when duration's value be 0ms, Causing a null pointer exception here.
Long
durationObj
=
span
.
duration
();
long
duration
=
(
durationObj
==
null
)
?
0
:
durationObj
.
longValue
()
/
1000
;
spanBuilder
.
setStartTime
(
startTime
);
spanBuilder
.
setEndTime
(
startTime
+
duration
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录