Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
ebd745c7
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,体验更适合开发者的 AI 搜索 >>
提交
ebd745c7
编写于
2月 19, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor code.
上级
6ac4b2d9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
24 deletion
+34
-24
skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/Tags.java
...ce/src/main/java/com/a/eye/skywalking/trace/tag/Tags.java
+23
-18
skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/SpanTestCase.java
...rc/test/java/com/a/eye/skywalking/trace/SpanTestCase.java
+4
-5
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/context/ContextManagerTestCase.java
.../com/a/eye/skywalking/context/ContextManagerTestCase.java
+6
-0
skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/PreparedStatementTracing.java
.../eye/skywalking/plugin/jdbc/PreparedStatementTracing.java
+1
-1
未找到文件。
skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/Tags.java
浏览文件 @
ebd745c7
...
...
@@ -23,51 +23,56 @@ public final class Tags {
public
static
final
IntTag
HTTP_STATUS
=
new
IntTag
(
"http.status_code"
);
/**
* SPAN_KIND represents the kind of span.
*
*/
public
static
final
StringTag
SPAN_KIND
=
new
StringTag
(
"span.kind"
);
/**
* SPAN_LAYER represents the kind of span.
* e.g. db=database, rpc=Remote Procedure Call, nosql=something like redis/memcache
*/
public
static
final
class
SPAN_
KIND
{
private
static
StringTag
SPAN_
KIND_TAG
=
new
StringTag
(
"span.kind
"
);
public
static
final
class
SPAN_
LAYER
{
private
static
StringTag
SPAN_
LAYER_TAG
=
new
StringTag
(
"span.layer
"
);
private
static
final
String
DB_
KIND
=
"db"
;
private
static
final
String
RPC_
KIND
=
"rpc"
;
private
static
final
String
NOSQL_
KIND
=
"nosql"
;
private
static
final
String
HTTP_
KIND
=
"http"
;
private
static
final
String
DB_
LAYER
=
"db"
;
private
static
final
String
RPC_
LAYER
=
"rpc"
;
private
static
final
String
NOSQL_
LAYER
=
"nosql"
;
private
static
final
String
HTTP_
LAYER
=
"http"
;
public
static
void
asDBAccess
(
Span
span
){
SPAN_
KIND_TAG
.
set
(
span
,
DB_KIND
);
SPAN_
LAYER_TAG
.
set
(
span
,
DB_LAYER
);
}
public
static
void
asRPC
(
Span
span
){
SPAN_
KIND_TAG
.
set
(
span
,
RPC_KIND
);
SPAN_
LAYER_TAG
.
set
(
span
,
RPC_LAYER
);
}
public
static
void
asNoSQL
(
Span
span
){
SPAN_
KIND_TAG
.
set
(
span
,
NOSQL_KIND
);
SPAN_
LAYER_TAG
.
set
(
span
,
NOSQL_LAYER
);
}
public
static
void
asHttp
(
Span
span
){
SPAN_
KIND_TAG
.
set
(
span
,
HTTP_KIND
);
SPAN_
LAYER_TAG
.
set
(
span
,
HTTP_LAYER
);
}
public
static
String
get
(
Span
span
){
return
SPAN_
KIND
_TAG
.
get
(
span
);
return
SPAN_
LAYER
_TAG
.
get
(
span
);
}
public
static
boolean
isDBAccess
(
Span
span
){
return
DB_
KIND
.
equals
(
get
(
span
));
return
DB_
LAYER
.
equals
(
get
(
span
));
}
public
static
boolean
isRPC
(
Span
span
){
return
RPC_
KIND
.
equals
(
get
(
span
));
return
RPC_
LAYER
.
equals
(
get
(
span
));
}
public
static
boolean
isNoSQL
(
Span
span
){
return
NOSQL_
KIND
.
equals
(
get
(
span
));
return
NOSQL_
LAYER
.
equals
(
get
(
span
));
}
public
static
boolean
isHttp
(
Span
span
){
return
HTTP_
KIND
.
equals
(
get
(
span
));
return
HTTP_
LAYER
.
equals
(
get
(
span
));
}
}
...
...
@@ -83,9 +88,9 @@ public final class Tags {
public
static
final
BooleanTag
ERROR
=
new
BooleanTag
(
"error"
);
/**
* PEER_HOST
_IPV4 records IPv4 host address of the peer
.
* PEER_HOST
records host address of the peer, maybe IPV4, IPV6 or hostname
.
*/
public
static
final
IntTag
PEER_HOST_IPV4
=
new
IntTag
(
"peer.ipv4
"
);
public
static
final
StringTag
PEER_HOST
=
new
StringTag
(
"peer.host
"
);
/**
* DB_URL records the url of the database access.
...
...
skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/SpanTestCase.java
浏览文件 @
ebd745c7
package
com.a.eye.skywalking.trace
;
import
com.a.eye.skywalking.trace.tag.Tags
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
org.junit.Assert
;
...
...
@@ -38,9 +37,9 @@ public class SpanTestCase {
@Test
public
void
testSetTag
()
{
Span
span1
=
new
Span
(
0
,
"serviceA"
);
Tags
.
SPAN_
KIND
.
asHttp
(
span1
);
Tags
.
SPAN_
LAYER
.
asHttp
(
span1
);
Tags
.
COMPONENT
.
set
(
span1
,
"Spring"
);
Tags
.
PEER_HOST
_IPV4
.
set
(
span1
,
ipToInt
(
"127.0.0.1"
));
Tags
.
PEER_HOST
.
set
(
span1
,
ipToInt
(
"127.0.0.1"
));
Tags
.
ERROR
.
set
(
span1
,
true
);
Tags
.
HTTP_STATUS
.
set
(
span1
,
302
);
Tags
.
HTTP_URL
.
set
(
span1
,
"http://127.0.0.1/serviceA"
);
...
...
@@ -49,8 +48,8 @@ public class SpanTestCase {
Map
<
String
,
Object
>
tags
=
span1
.
getTags
();
Assert
.
assertEquals
(
8
,
tags
.
size
());
Assert
.
assertTrue
(
Tags
.
SPAN_
KIND
.
isHttp
(
span1
));
Assert
.
assertEquals
(
"127.0.0.1"
,
intToIp
(
Tags
.
PEER_HOST
_IPV4
.
get
(
span1
)));
Assert
.
assertTrue
(
Tags
.
SPAN_
LAYER
.
isHttp
(
span1
));
Assert
.
assertEquals
(
"127.0.0.1"
,
intToIp
(
Tags
.
PEER_HOST
.
get
(
span1
)));
Assert
.
assertTrue
(
Tags
.
ERROR
.
get
(
span1
));
}
...
...
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/context/ContextManagerTestCase.java
浏览文件 @
ebd745c7
...
...
@@ -3,6 +3,7 @@ package com.a.eye.skywalking.context;
import
com.a.eye.skywalking.trace.Span
;
import
com.a.eye.skywalking.trace.TraceSegment
;
import
com.a.eye.skywalking.trace.tag.Tags
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
@@ -24,4 +25,9 @@ public class ContextManagerTestCase {
Assert
.
assertEquals
(
span
,
segment
.
getSpans
().
get
(
0
));
}
@After
public
void
reset
(){
TracerContext
.
ListenerManager
.
remove
(
TestTracerContextListener
.
INSTANCE
);
}
}
skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/PreparedStatementTracing.java
浏览文件 @
ebd745c7
...
...
@@ -17,7 +17,7 @@ public class PreparedStatementTracing {
throws
SQLException
{
Span
span
=
ContextManager
.
INSTANCE
.
createSpan
(
"JDBC/PreparedStatement/"
+
method
);
try
{
Tags
.
SPAN_
KIND
.
asDBAccess
(
span
);
Tags
.
SPAN_
LAYER
.
asDBAccess
(
span
);
Tags
.
DB_URL
.
set
(
span
,
connectInfo
);
Tags
.
DB_SQL
.
set
(
span
,
sql
);
return
exec
.
exe
(
realStatement
,
sql
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录