Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
5f6dd33c
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
5f6dd33c
编写于
3月 22, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix jedis missing tag: span.kind.
上级
590d93f0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
20 deletion
+57
-20
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceManager.java
...in/java/com/a/eye/skywalking/api/boot/ServiceManager.java
+16
-17
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/sampling/SamplingService.java
...va/com/a/eye/skywalking/api/sampling/SamplingService.java
+4
-3
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/sampling/SamplingServiceTest.java
...om/a/eye/skywalking/api/sampling/SamplingServiceTest.java
+36
-0
skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptor.java
...ye/skywalking/plugin/jedis/v2/JedisMethodInterceptor.java
+1
-0
未找到文件。
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceManager.java
浏览文件 @
5f6dd33c
...
...
@@ -17,36 +17,35 @@ public enum ServiceManager {
INSTANCE
;
private
static
ILog
logger
=
LogManager
.
getLogger
(
StatusBootService
.
class
);
private
volatile
boolean
isStarted
=
false
;
private
Map
<
Class
,
BootService
>
bootedServices
;
private
Map
<
Class
,
BootService
>
bootedServices
=
new
HashMap
<
Class
,
BootService
>();
public
void
boot
()
{
if
(!
isStarted
)
{
bootedServices
=
loadAllServices
();
}
private
Map
<
Class
,
BootService
>
loadAllServices
()
{
HashMap
<
Class
,
BootService
>
bootedServices
=
new
HashMap
<
Class
,
BootService
>();
Iterator
<
BootService
>
serviceIterator
=
load
().
iterator
();
while
(
serviceIterator
.
hasNext
())
{
BootService
bootService
=
serviceIterator
.
next
();
try
{
bootedServices
=
new
HashMap
<
Class
,
BootService
>();
Iterator
<
BootService
>
serviceIterator
=
load
().
iterator
();
while
(
serviceIterator
.
hasNext
())
{
BootService
bootService
=
serviceIterator
.
next
();
try
{
bootService
.
bootUp
();
bootedServices
.
put
(
bootService
.
getClass
(),
bootService
);
}
catch
(
Throwable
e
)
{
logger
.
error
(
e
,
"ServiceManager try to start [{}] fail."
,
bootService
.
getClass
().
getName
());
}
}
}
finally
{
isStarted
=
true
;
bootService
.
bootUp
();
bootedServices
.
put
(
bootService
.
getClass
(),
bootService
);
}
catch
(
Throwable
e
)
{
logger
.
error
(
e
,
"ServiceManager try to start [{}] fail."
,
bootService
.
getClass
().
getName
());
}
}
return
bootedServices
;
}
/**
* Find a {@link BootService} implementation, which is already started.
*
* @param serviceClass class name.
* @param <T> {@link BootService} implementation class.
* @return {@link BootService} instance
*/
public
<
T
extends
BootService
>
T
findService
(
Class
<
T
>
serviceClass
){
public
<
T
extends
BootService
>
T
findService
(
Class
<
T
>
serviceClass
)
{
return
(
T
)
bootedServices
.
get
(
serviceClass
);
}
...
...
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/sampling/SamplingService.java
浏览文件 @
5f6dd33c
...
...
@@ -21,7 +21,7 @@ public class SamplingService implements BootService {
private
volatile
boolean
on
=
false
;
private
volatile
int
rate
=
0
;
private
volatile
int
rollingSeed
=
0
;
private
volatile
int
rollingSeed
=
1
;
@Override
public
void
bootUp
()
throws
Throwable
{
...
...
@@ -39,9 +39,10 @@ public class SamplingService implements BootService {
public
void
trySampling
(
TraceSegment
segment
)
{
if
(
on
)
{
if
(
rollingSeed
++
!=
rate
)
{
if
(
rollingSeed
%
rate
!=
0
)
{
segment
.
setSampled
(
false
);
}
rollingSeed
++;
}
}
...
...
@@ -59,7 +60,7 @@ public class SamplingService implements BootService {
if
(
on
)
{
if
(!
segment
.
isSampled
()
&&
carrier
.
isSampled
())
{
segment
.
setSampled
(
true
);
this
.
rollingSeed
=
0
;
this
.
rollingSeed
=
1
;
}
}
}
...
...
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/sampling/SamplingServiceTest.java
0 → 100644
浏览文件 @
5f6dd33c
package
com.a.eye.skywalking.api.sampling
;
import
com.a.eye.skywalking.api.boot.ServiceManager
;
import
com.a.eye.skywalking.api.conf.Config
;
import
com.a.eye.skywalking.trace.TraceSegment
;
import
org.junit.AfterClass
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* @author wusheng
*/
public
class
SamplingServiceTest
{
@Test
public
void
test50Percent
(){
Config
.
Agent
.
SAMPLING_RATE
=
5000
;
ServiceManager
.
INSTANCE
.
boot
();
TraceSegment
segment
=
new
TraceSegment
();
Assert
.
assertTrue
(
segment
.
isSampled
());
SamplingService
service
=
ServiceManager
.
INSTANCE
.
findService
(
SamplingService
.
class
);
service
.
trySampling
(
segment
);
Assert
.
assertFalse
(
segment
.
isSampled
());
segment
=
new
TraceSegment
();
service
.
trySampling
(
segment
);
Assert
.
assertTrue
(
segment
.
isSampled
());
}
@AfterClass
public
static
void
clear
(){
Config
.
Agent
.
SAMPLING_RATE
=
10000
;
ServiceManager
.
INSTANCE
.
boot
();
}
}
skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptor.java
浏览文件 @
5f6dd33c
...
...
@@ -50,6 +50,7 @@ public class JedisMethodInterceptor extends NoCocurrencyAceessObject implements
Span
span
=
ContextManager
.
createSpan
(
"Jedis/"
+
interceptorContext
.
methodName
());
Tags
.
COMPONENT
.
set
(
span
,
REDIS_COMPONENT
);
Tags
.
DB_TYPE
.
set
(
span
,
REDIS_COMPONENT
);
Tags
.
SPAN_KIND
.
set
(
span
,
Tags
.
SPAN_KIND_CLIENT
);
tagPeer
(
span
,
context
);
Tags
.
SPAN_LAYER
.
asDB
(
span
);
if
(
StringUtil
.
isEmpty
(
context
.
get
(
KEY_OF_REDIS_HOST
,
String
.
class
)))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录