提交 fc19ce85 编写于 作者: wu-sheng's avatar wu-sheng

Take Adrian Cole ’s advice, remove http prefix of tag. Maybe still need some improvements.

上级 ebd745c7
...@@ -13,38 +13,48 @@ public final class Tags { ...@@ -13,38 +13,48 @@ public final class Tags {
} }
/** /**
* HTTP_URL records the url of the incoming request. * URL records the url of the incoming request.
*/ */
public static final StringTag HTTP_URL = new StringTag("http.url"); public static final StringTag URL = new StringTag("url");
/** /**
* HTTP_STATUS records the http status code of the response. * STATUS_CODE records the http status code of the response.
*/ */
public static final IntTag HTTP_STATUS = new IntTag("http.status_code"); public static final IntTag STATUS_CODE = new IntTag("status_code");
/** /**
* * SPAN_KIND hints at the relationship between spans, e.g. client/server.
*/ */
public static final StringTag SPAN_KIND = new StringTag("span.kind"); public static final StringTag SPAN_KIND = new StringTag("span.kind");
/**
* A constant for setting the span kind to indicate that it represents a server span.
*/
public static final String SPAN_KIND_SERVER = "server";
/**
* A constant for setting the span kind to indicate that it represents a client span.
*/
public static final String SPAN_KIND_CLIENT = "client";
/** /**
* SPAN_LAYER represents the kind of span. * SPAN_LAYER represents the kind of span.
* e.g. db=database, rpc=Remote Procedure Call, nosql=something like redis/memcache * e.g. db=database; rpc=Remote Procedure Call Framework, like motan, thift; nosql=something like redis/memcache
*/ */
public static final class SPAN_LAYER { public static final class SPAN_LAYER {
private static StringTag SPAN_LAYER_TAG = new StringTag("span.layer"); private static StringTag SPAN_LAYER_TAG = new StringTag("span.layer");
private static final String DB_LAYER = "db"; private static final String RDB_LAYER = "rda";
private static final String RPC_LAYER = "rpc"; private static final String RPC_FRAMEWORK_LAYER = "rpc";
private static final String NOSQL_LAYER = "nosql"; private static final String NOSQL_LAYER = "nosql";
private static final String HTTP_LAYER = "http"; private static final String HTTP_LAYER = "http";
public static void asDBAccess(Span span){ public static void asDBAccess(Span span){
SPAN_LAYER_TAG.set(span, DB_LAYER); SPAN_LAYER_TAG.set(span, RDB_LAYER);
} }
public static void asRPC(Span span){ public static void asRPCFramework(Span span){
SPAN_LAYER_TAG.set(span, RPC_LAYER); SPAN_LAYER_TAG.set(span, RPC_FRAMEWORK_LAYER);
} }
public static void asNoSQL(Span span){ public static void asNoSQL(Span span){
...@@ -60,11 +70,11 @@ public final class Tags { ...@@ -60,11 +70,11 @@ public final class Tags {
} }
public static boolean isDBAccess(Span span){ public static boolean isDBAccess(Span span){
return DB_LAYER.equals(get(span)); return RDB_LAYER.equals(get(span));
} }
public static boolean isRPC(Span span){ public static boolean isRPCFramework(Span span){
return RPC_LAYER.equals(get(span)); return RPC_FRAMEWORK_LAYER.equals(get(span));
} }
public static boolean isNoSQL(Span span){ public static boolean isNoSQL(Span span){
...@@ -98,7 +108,7 @@ public final class Tags { ...@@ -98,7 +108,7 @@ public final class Tags {
public static final StringTag DB_URL = new StringTag("db.url"); public static final StringTag DB_URL = new StringTag("db.url");
/** /**
* DB_SQL records the sql statement of the database access. * DB_STATEMENT records the sql statement of the database access.
*/ */
public static final StringTag DB_SQL = new StringTag("db.statement"); public static final StringTag DB_STATEMENT = new StringTag("db.statement");
} }
...@@ -41,10 +41,10 @@ public class SpanTestCase { ...@@ -41,10 +41,10 @@ public class SpanTestCase {
Tags.COMPONENT.set(span1, "Spring"); Tags.COMPONENT.set(span1, "Spring");
Tags.PEER_HOST.set(span1, ipToInt("127.0.0.1")); Tags.PEER_HOST.set(span1, ipToInt("127.0.0.1"));
Tags.ERROR.set(span1, true); Tags.ERROR.set(span1, true);
Tags.HTTP_STATUS.set(span1, 302); Tags.STATUS_CODE.set(span1, 302);
Tags.HTTP_URL.set(span1, "http://127.0.0.1/serviceA"); Tags.URL.set(span1, "http://127.0.0.1/serviceA");
Tags.DB_URL.set(span1, "jdbc:127.0.0.1:user"); Tags.DB_URL.set(span1, "jdbc:127.0.0.1:user");
Tags.DB_SQL.set(span1, "select * from users"); Tags.DB_STATEMENT.set(span1, "select * from users");
Map<String, Object> tags = span1.getTags(); Map<String, Object> tags = span1.getTags();
Assert.assertEquals(8, tags.size()); Assert.assertEquals(8, tags.size());
......
...@@ -19,7 +19,7 @@ public class PreparedStatementTracing { ...@@ -19,7 +19,7 @@ public class PreparedStatementTracing {
try { try {
Tags.SPAN_LAYER.asDBAccess(span); Tags.SPAN_LAYER.asDBAccess(span);
Tags.DB_URL.set(span, connectInfo); Tags.DB_URL.set(span, connectInfo);
Tags.DB_SQL.set(span, sql); Tags.DB_STATEMENT.set(span, sql);
return exec.exe(realStatement, sql); return exec.exe(realStatement, sql);
} catch (SQLException e) { } catch (SQLException e) {
span.log(e); span.log(e);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册