diff --git a/src/main/java/com/profiler/context/AsyncTrace.java b/src/main/java/com/profiler/context/AsyncTrace.java index e1b5a359a..802911361 100644 --- a/src/main/java/com/profiler/context/AsyncTrace.java +++ b/src/main/java/com/profiler/context/AsyncTrace.java @@ -100,11 +100,22 @@ public class AsyncTrace { subSpan.addAnnotation(new Annotation(key, value)); } - - public void recordRpcName(final ServiceType serviceType, final String service, final String rpc) { + public void recordServiceType(final ServiceType serviceType) { this.subSpan.setServiceType(serviceType); - this.subSpan.setServiceName(service); - this.subSpan.setRpc(rpc); + } + + public void recordServiceName(final String serviceName) { + this.subSpan.setServiceName(serviceName); + } + + public void recordRpcName(final String rpcName) { + this.subSpan.setRpc(rpcName); + + } + + + public void recordDestinationId(String destinationId) { + this.subSpan.setDestionationId(destinationId); } // TODO: final String... endPoint로 받으면 합치는데 비용이 들어가 그냥 한번에 받는게 나을것 같음. @@ -150,4 +161,6 @@ public class AsyncTrace { } return false; } + + } diff --git a/src/main/java/com/profiler/context/SubSpan.java b/src/main/java/com/profiler/context/SubSpan.java index 5bf877c0c..25deb91ed 100644 --- a/src/main/java/com/profiler/context/SubSpan.java +++ b/src/main/java/com/profiler/context/SubSpan.java @@ -22,8 +22,12 @@ public class SubSpan implements Thriftable { private String serviceName; private String rpc; private ServiceType serviceType; + private String endPoint; + private String destionationId; + private List destinationAddress; + private final List annotations = new ArrayList(5); private int nextSpanId = -1; @@ -81,6 +85,22 @@ public class SubSpan implements Thriftable { this.endPoint = endPoint; } + public String getDestionationId() { + return destionationId; + } + + public void setDestionationId(String destionationId) { + this.destionationId = destionationId; + } + + public List getDestinationAddress() { + return destinationAddress; + } + + public void setDestinationAddress(List destinationAddress) { + this.destinationAddress = destinationAddress; + } + public void setStartTime(long startTime) { this.startTime = startTime; } @@ -180,6 +200,7 @@ public class SubSpan implements Thriftable { } subSpan.setEndPoint(endPoint); + subSpan.setDestinationId(this.destionationId); // 여기서 데이터 인코딩을 하자. List annotationList = new ArrayList(annotations.size()); @@ -198,4 +219,8 @@ public class SubSpan implements Thriftable { return subSpan; } + + public void setDestinationAddress() { + //To change body of created methods use File | Settings | File Templates. + } } diff --git a/src/main/java/com/profiler/context/SubSpanList.java b/src/main/java/com/profiler/context/SubSpanList.java index 22ba356e4..0d9e4e388 100644 --- a/src/main/java/com/profiler/context/SubSpanList.java +++ b/src/main/java/com/profiler/context/SubSpanList.java @@ -58,6 +58,7 @@ public class SubSpanList implements Thriftable { tSubSpan.setServiceType(subSpan.getServiceType().getCode()); tSubSpan.setEndPoint(subSpan.getEndPoint()); + tSubSpan.setDestinationId(subSpan.getDestionationId()); // 여기서 데이터 인코딩을 하자. List annotationList = new ArrayList(subSpan.getAnnotationSize()); diff --git a/src/main/java/com/profiler/context/Trace.java b/src/main/java/com/profiler/context/Trace.java index 5d30d430a..071d3b0d3 100644 --- a/src/main/java/com/profiler/context/Trace.java +++ b/src/main/java/com/profiler/context/Trace.java @@ -6,6 +6,7 @@ import com.profiler.common.util.ParsingResult; import com.profiler.interceptor.MethodDescriptor; import com.profiler.logging.LoggingUtils; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -315,6 +316,28 @@ public final class Trace { } + public void recordDestinationId(final String destinationId) { + // TODO API 단일화 필요. + StackFrame currentStackFrame = getCurrentStackFrame(); + if (currentStackFrame instanceof SubStackFrame) { + SubSpan subSpan = ((SubStackFrame) currentStackFrame).getSubSpan(); + subSpan.setDestionationId(destinationId); + } + } + + public void recordDestinationAddress(List address) { + // TODO API 단일화 필요. + StackFrame currentStackFrame = getCurrentStackFrame(); + if (currentStackFrame instanceof SubStackFrame) { + SubSpan subSpan = ((SubStackFrame) currentStackFrame).getSubSpan(); + subSpan.setDestinationAddress(); + } + } + + public void recordDestinationAddressList(List addressList) { + //To change body of created methods use File | Settings | File Templates. + } + public void recordEndPoint(final String endPoint) { // TODO API 단일화 필요. StackFrame currentStackFrame = getCurrentStackFrame(); @@ -364,4 +387,6 @@ public final class Trace { this.traceContext = traceContext; } + + } \ No newline at end of file diff --git a/src/main/java/com/profiler/modifier/arcus/interceptors/BaseOperationTransitionStateInterceptor.java b/src/main/java/com/profiler/modifier/arcus/interceptors/BaseOperationTransitionStateInterceptor.java index 3f87edb96..a29135e99 100644 --- a/src/main/java/com/profiler/modifier/arcus/interceptors/BaseOperationTransitionStateInterceptor.java +++ b/src/main/java/com/profiler/modifier/arcus/interceptors/BaseOperationTransitionStateInterceptor.java @@ -72,8 +72,12 @@ public class BaseOperationTransitionStateInterceptor implements StaticBeforeInte if(serviceCode.equals(ServiceType.MEMCACHED.getDesc())) { svcType = ServiceType.MEMCACHED; } - - asyncTrace.recordRpcName(svcType, serviceCode, baseOperation.getClass().getSimpleName()); + + asyncTrace.recordServiceType(svcType); + asyncTrace.recordServiceName(serviceCode); + asyncTrace.recordRpcName(baseOperation.getClass().getSimpleName()); + + asyncTrace.recordDestinationId(serviceCode); String cmd = getCommand(baseOperation); asyncTrace.recordAttibute(AnnotationKey.ARCUS_COMMAND, cmd); diff --git a/src/main/java/com/profiler/modifier/bloc/handler/interceptors/ExecuteMethodInterceptor.java b/src/main/java/com/profiler/modifier/bloc/handler/interceptors/ExecuteMethodInterceptor.java index 81bedbc49..425ecb475 100644 --- a/src/main/java/com/profiler/modifier/bloc/handler/interceptors/ExecuteMethodInterceptor.java +++ b/src/main/java/com/profiler/modifier/bloc/handler/interceptors/ExecuteMethodInterceptor.java @@ -73,6 +73,7 @@ public class ExecuteMethodInterceptor implements StaticAroundInterceptor, ByteCo trace.recordEndPoint(request.protocol().toString() + ":" + request.serverName().toString() + ":" + request.getServerPort()); + trace.recordDestinationId(request.serverName().toString() + ":" + request.getServerPort()); trace.recordAttribute(AnnotationKey.HTTP_URL, request.requestURI().toString()); if (parameters != null && parameters.length() > 0) { trace.recordAttribute(AnnotationKey.HTTP_PARAM, parameters); diff --git a/src/main/java/com/profiler/modifier/connector/interceptors/Execute2MethodInterceptor.java b/src/main/java/com/profiler/modifier/connector/interceptors/Execute2MethodInterceptor.java index f25f10300..80df38fe8 100644 --- a/src/main/java/com/profiler/modifier/connector/interceptors/Execute2MethodInterceptor.java +++ b/src/main/java/com/profiler/modifier/connector/interceptors/Execute2MethodInterceptor.java @@ -67,6 +67,7 @@ public class Execute2MethodInterceptor implements StaticAroundInterceptor, ByteC int port = host.getPort(); trace.recordEndPoint(request.getProtocolVersion() + ":" + host.getHostName() + ((port > 0) ? ":" + port : "")); + trace.recordDestinationId(host.getHostName() + ((port > 0) ? ":" + port : "")); trace.recordAttribute(AnnotationKey.HTTP_URL, request.getRequestLine().getUri()); } diff --git a/src/main/java/com/profiler/modifier/connector/interceptors/ExecuteMethodInterceptor.java b/src/main/java/com/profiler/modifier/connector/interceptors/ExecuteMethodInterceptor.java index 48cf3ff96..38d6a1ec8 100644 --- a/src/main/java/com/profiler/modifier/connector/interceptors/ExecuteMethodInterceptor.java +++ b/src/main/java/com/profiler/modifier/connector/interceptors/ExecuteMethodInterceptor.java @@ -68,6 +68,8 @@ public class ExecuteMethodInterceptor implements StaticAroundInterceptor, ByteCo int port = host.getPort(); trace.recordEndPoint(request.getProtocolVersion() + ":" + host.getHostName() + ((port > 0) ? ":" + port : "")); + trace.recordDestinationId(host.getHostName() + ((port > 0) ? ":" + port : "")); + trace.recordAttribute(AnnotationKey.HTTP_URL, request.getRequestLine().getUri()); } diff --git a/src/main/java/com/profiler/modifier/db/interceptor/DriverConnectInterceptor.java b/src/main/java/com/profiler/modifier/db/interceptor/DriverConnectInterceptor.java index a3b8bb7ea..2e3914736 100644 --- a/src/main/java/com/profiler/modifier/db/interceptor/DriverConnectInterceptor.java +++ b/src/main/java/com/profiler/modifier/db/interceptor/DriverConnectInterceptor.java @@ -13,6 +13,7 @@ import com.profiler.util.MetaObject; import com.profiler.util.StringUtils; import java.util.Arrays; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -77,6 +78,10 @@ public class DriverConnectInterceptor implements StaticAroundInterceptor, ByteCo trace.recordRpcName(databaseInfo.getUrl()); trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); + + trace.recordApi(descriptor, new Object[]{args[0]}); trace.recordException(result); diff --git a/src/main/java/com/profiler/modifier/db/interceptor/PreparedStatementCreateInterceptor.java b/src/main/java/com/profiler/modifier/db/interceptor/PreparedStatementCreateInterceptor.java index 751fff1bc..7dc19b0c6 100644 --- a/src/main/java/com/profiler/modifier/db/interceptor/PreparedStatementCreateInterceptor.java +++ b/src/main/java/com/profiler/modifier/db/interceptor/PreparedStatementCreateInterceptor.java @@ -52,6 +52,8 @@ public class PreparedStatementCreateInterceptor implements StaticAroundIntercept trace.recordRpcName(databaseInfo.getUrl()); trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); } diff --git a/src/main/java/com/profiler/modifier/db/interceptor/PreparedStatementExecuteQueryInterceptor.java b/src/main/java/com/profiler/modifier/db/interceptor/PreparedStatementExecuteQueryInterceptor.java index 77cb736df..6d1d87686 100644 --- a/src/main/java/com/profiler/modifier/db/interceptor/PreparedStatementExecuteQueryInterceptor.java +++ b/src/main/java/com/profiler/modifier/db/interceptor/PreparedStatementExecuteQueryInterceptor.java @@ -56,6 +56,9 @@ public class PreparedStatementExecuteQueryInterceptor implements StaticAroundInt trace.recordRpcName(databaseInfo.getUrl()); trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); + ParsingResult parsingResult = (ParsingResult) getSql.invoke(target); trace.recordSqlParsingResult(parsingResult); diff --git a/src/main/java/com/profiler/modifier/db/interceptor/StatementExecuteQueryInterceptor.java b/src/main/java/com/profiler/modifier/db/interceptor/StatementExecuteQueryInterceptor.java index 01b674b4f..80092b2d4 100644 --- a/src/main/java/com/profiler/modifier/db/interceptor/StatementExecuteQueryInterceptor.java +++ b/src/main/java/com/profiler/modifier/db/interceptor/StatementExecuteQueryInterceptor.java @@ -53,6 +53,8 @@ public class StatementExecuteQueryInterceptor implements StaticAroundInterceptor trace.recordRpcName(databaseInfo.getUrl()); trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); } catch (Exception e) { diff --git a/src/main/java/com/profiler/modifier/db/interceptor/StatementExecuteUpdateInterceptor.java b/src/main/java/com/profiler/modifier/db/interceptor/StatementExecuteUpdateInterceptor.java index e2347c9f1..ac0067cea 100644 --- a/src/main/java/com/profiler/modifier/db/interceptor/StatementExecuteUpdateInterceptor.java +++ b/src/main/java/com/profiler/modifier/db/interceptor/StatementExecuteUpdateInterceptor.java @@ -54,6 +54,9 @@ public class StatementExecuteUpdateInterceptor implements StaticAroundIntercepto trace.recordRpcName(databaseInfo.getUrl()); trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); + trace.recordApi(descriptor); if (args.length > 0) { Object arg = args[0]; diff --git a/src/main/java/com/profiler/modifier/db/interceptor/TransactionInterceptor.java b/src/main/java/com/profiler/modifier/db/interceptor/TransactionInterceptor.java index bf15de480..ced35b0f8 100644 --- a/src/main/java/com/profiler/modifier/db/interceptor/TransactionInterceptor.java +++ b/src/main/java/com/profiler/modifier/db/interceptor/TransactionInterceptor.java @@ -84,6 +84,8 @@ public class TransactionInterceptor implements StaticAroundInterceptor, ByteCode trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); } private void afterStartTransaction(Trace trace, Connection target, Object[] arg, Object result) { @@ -135,6 +137,8 @@ public class TransactionInterceptor implements StaticAroundInterceptor, ByteCode trace.recordRpcName(databaseInfo.getUrl()); trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); // trace.record(Annotation.ClientSend); } @@ -148,6 +152,8 @@ public class TransactionInterceptor implements StaticAroundInterceptor, ByteCode trace.recordRpcName(databaseInfo.getUrl()); trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); trace.recordApi(descriptor); // trace.recordApi(apiId); @@ -184,6 +190,8 @@ public class TransactionInterceptor implements StaticAroundInterceptor, ByteCode trace.recordRpcName(databaseInfo.getUrl()); trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); } private void afterRollback(Trace trace, Connection target, Object result) { @@ -196,6 +204,8 @@ public class TransactionInterceptor implements StaticAroundInterceptor, ByteCode trace.recordRpcName(databaseInfo.getUrl()); trace.recordEndPoint(databaseInfo.getUrl()); + trace.recordDestinationId(databaseInfo.getDatabaseId()); + trace.recordDestinationAddress(databaseInfo.getHost()); trace.recordApi(descriptor); // trace.recordApi(apiId); diff --git a/src/main/java/com/profiler/modifier/db/util/DatabaseInfo.java b/src/main/java/com/profiler/modifier/db/util/DatabaseInfo.java index 1569e46a0..6518884f0 100644 --- a/src/main/java/com/profiler/modifier/db/util/DatabaseInfo.java +++ b/src/main/java/com/profiler/modifier/db/util/DatabaseInfo.java @@ -2,6 +2,8 @@ package com.profiler.modifier.db.util; import com.profiler.common.ServiceType; +import java.util.List; + /** * */ @@ -13,30 +15,23 @@ public class DatabaseInfo { // 입력된 url을 보정하지 않은 값 private String realUrl; private String normalizedUrl; - private String host; - private String port; + private List host; - public DatabaseInfo(ServiceType type, ServiceType executeQueryType, String realUrl, String normalizedUrl, String host, String port, String databaseId) { + public DatabaseInfo(ServiceType type, ServiceType executeQueryType, String realUrl, String normalizedUrl, List host, String databaseId) { this.type = type; this.executeQueryType = executeQueryType; this.realUrl = realUrl; this.normalizedUrl = normalizedUrl; this.host = host; - this.port = port; this.databaseId = databaseId; } - @Deprecated - public String getHost() { + + public List getHost() { // host와 port의 경우 replication 설정등으로 n개가 될수 있어 애매하다. return host; } - @Deprecated - public String getPort() { - // host와 port의 경우 replication 설정등으로 n개가 될수 있어 애매하다. - return port; - } public String getDatabaseId() { return databaseId; @@ -66,10 +61,7 @@ public class DatabaseInfo { ", databaseId='" + databaseId + '\'' + ", realUrl='" + realUrl + '\'' + ", normalizedUrl='" + normalizedUrl + '\'' + - ", host='" + host + '\'' + - ", port='" + port + '\'' + + ", host=" + host + '}'; } - - } diff --git a/src/main/java/com/profiler/modifier/db/util/JDBCUrlParser.java b/src/main/java/com/profiler/modifier/db/util/JDBCUrlParser.java index 080cc5ec8..9ef7ff573 100644 --- a/src/main/java/com/profiler/modifier/db/util/JDBCUrlParser.java +++ b/src/main/java/com/profiler/modifier/db/util/JDBCUrlParser.java @@ -2,6 +2,9 @@ package com.profiler.modifier.db.util; import com.profiler.common.ServiceType; +import java.util.ArrayList; +import java.util.List; + /** * */ @@ -14,8 +17,9 @@ public class JDBCUrlParser { if (lowCaseURL.startsWith("jdbc:oracle")) { return parseOracle(url); } - - return new DatabaseInfo(ServiceType.UNKNOWN_DB, ServiceType.UNKNOWN_DB_EXECUTE_QUERY, url, url, "error", "error", "error"); + List list = new ArrayList(); + list.add("error"); + return new DatabaseInfo(ServiceType.UNKNOWN_DB, ServiceType.UNKNOWN_DB_EXECUTE_QUERY, url, url, list, "error"); // else if (url.indexOf("jdbc:oracle") >= 0) { // maker.lower().after("jdbc:oracle:").after(':'); // info.type = TYPE.ORACLE; @@ -72,10 +76,14 @@ public class JDBCUrlParser { // jdbc:mysql://10.98.133.22:3306/test_lucy_db StringMaker maker = new StringMaker(url); maker.after("jdbc:mysql:"); - String host = maker.after("//").before('/').before(':').value(); - String port = maker.next().after(':').before('/').value(); + // 10.98.133.22:3306 replacation driver같은 경우 n개가 가능할듯. + String host = maker.after("//").before('/').value(); + List hostList = new ArrayList(1); + hostList.add(host); +// String port = maker.next().after(':').before('/').value(); + String databaseId = maker.next().afterLast('/').before('?').value(); String normalizedUrl = maker.clear().before('?').value(); - return new DatabaseInfo(ServiceType.MYSQL, ServiceType.MYSQL_EXECUTE_QUERY, url, normalizedUrl, host, port, databaseId); + return new DatabaseInfo(ServiceType.MYSQL, ServiceType.MYSQL_EXECUTE_QUERY, url, normalizedUrl, hostList, databaseId); } } diff --git a/src/main/java/com/profiler/modifier/method/interceptors/MethodInterceptor.java b/src/main/java/com/profiler/modifier/method/interceptors/MethodInterceptor.java index e078171a0..3985030d6 100644 --- a/src/main/java/com/profiler/modifier/method/interceptors/MethodInterceptor.java +++ b/src/main/java/com/profiler/modifier/method/interceptors/MethodInterceptor.java @@ -5,10 +5,7 @@ import java.util.logging.Logger; import com.profiler.common.ServiceType; import com.profiler.context.Trace; import com.profiler.context.TraceContext; -import com.profiler.interceptor.ByteCodeMethodDescriptorSupport; -import com.profiler.interceptor.MethodDescriptor; -import com.profiler.interceptor.StaticAroundInterceptor; -import com.profiler.interceptor.TraceContextSupport; +import com.profiler.interceptor.*; import com.profiler.logging.LoggingUtils; /** @@ -16,13 +13,14 @@ import com.profiler.logging.LoggingUtils; * @author netspider * */ -public class MethodInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport { +public class MethodInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, ServiceTypeSupport, TraceContextSupport { private final Logger logger = Logger.getLogger(MethodInterceptor.class.getName()); private final boolean isDebug = LoggingUtils.isDebug(logger); private MethodDescriptor descriptor; private TraceContext traceContext; + private ServiceType serviceType = ServiceType.INTERNAL_METHOD; @Override public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) { @@ -36,7 +34,7 @@ public class MethodInterceptor implements StaticAroundInterceptor, ByteCodeMetho } trace.traceBlockBegin(); - trace.recordServiceType(ServiceType.INTERNAL_METHOD); + trace.recordServiceType(serviceType); // trace.recordRpcName(ServiceType.INTERNAL_METHOD, null, null); trace.markBeforeTime(); } @@ -58,7 +56,11 @@ public class MethodInterceptor implements StaticAroundInterceptor, ByteCodeMetho trace.traceBlockEnd(); } - @Override + public void setServiceType(ServiceType serviceType) { + this.serviceType = serviceType; + } + + @Override public void setMethodDescriptor(MethodDescriptor descriptor) { this.descriptor = descriptor; TraceContext traceContext = TraceContext.getTraceContext(); diff --git a/src/main/java/com/profiler/modifier/servlet/SpringFrameworkServletModifier.java b/src/main/java/com/profiler/modifier/servlet/SpringFrameworkServletModifier.java index 863ee6c3f..65ccd1fe7 100644 --- a/src/main/java/com/profiler/modifier/servlet/SpringFrameworkServletModifier.java +++ b/src/main/java/com/profiler/modifier/servlet/SpringFrameworkServletModifier.java @@ -5,6 +5,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.profiler.Agent; +import com.profiler.common.ServiceType; import com.profiler.interceptor.Interceptor; import com.profiler.interceptor.bci.ByteCodeInstrumentor; import com.profiler.interceptor.bci.InstrumentClass; @@ -37,14 +38,18 @@ public class SpringFrameworkServletModifier extends AbstractModifier { try { Interceptor doGetInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.method.interceptors.MethodInterceptor"); - Interceptor doPostInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.method.interceptors.MethodInterceptor"); + setServiceType(doGetInterceptor, ServiceType.SPRING_MVC); + setTraceContext(doGetInterceptor); + + Interceptor doPostInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.method.interceptors.MethodInterceptor"); + setServiceType(doPostInterceptor, ServiceType.SPRING_MVC); + setTraceContext(doPostInterceptor); + - setTraceContext(doGetInterceptor); - setTraceContext(doPostInterceptor); InstrumentClass servlet = byteCodeInstrumentor.getClass(javassistClassName); - servlet.addInterceptor("doGet", new String[] { "javax.servlet.http.HttpServletRequest", "javax.servlet.http.HttpServletResponse" }, doGetInterceptor); + servlet.addInterceptor("doPost", new String[] { "javax.servlet.http.HttpServletRequest", "javax.servlet.http.HttpServletResponse" }, doPostInterceptor); return servlet.toBytecode(); diff --git a/src/main/java/com/profiler/modifier/servlet/interceptors/DoXXXInterceptor.java b/src/main/java/com/profiler/modifier/servlet/interceptors/DoXXXInterceptor.java index 2d7c1dd17..783970af5 100644 --- a/src/main/java/com/profiler/modifier/servlet/interceptors/DoXXXInterceptor.java +++ b/src/main/java/com/profiler/modifier/servlet/interceptors/DoXXXInterceptor.java @@ -94,6 +94,7 @@ public class DoXXXInterceptor implements StaticAroundInterceptor, ByteCodeMethod int port = request.getServerPort(); trace.recordEndPoint(request.getProtocol() + ":" + request.getServerName() + ((port > 0) ? ":" + port : "")); + trace.recordDestinationId(request.getServerName() + ((port > 0) ? ":" + port : "")); trace.recordAttribute(AnnotationKey.HTTP_URL, request.getRequestURI()); } catch (Exception e) { if (logger.isLoggable(Level.WARNING)) { diff --git a/src/main/java/com/profiler/modifier/tomcat/interceptors/StandardHostValveInvokeInterceptor.java b/src/main/java/com/profiler/modifier/tomcat/interceptors/StandardHostValveInvokeInterceptor.java index 9ec67b395..842e71bc0 100644 --- a/src/main/java/com/profiler/modifier/tomcat/interceptors/StandardHostValveInvokeInterceptor.java +++ b/src/main/java/com/profiler/modifier/tomcat/interceptors/StandardHostValveInvokeInterceptor.java @@ -71,7 +71,7 @@ public class StandardHostValveInvokeInterceptor implements StaticAroundIntercept trace.recordRpcName(requestURL); int port = request.getServerPort(); - trace.recordEndPoint(request.getProtocol() + ":" + request.getServerName() + ((port > 0) ? ":" + port : "")); + trace.recordEndPoint(request.getServerName() + ((port > 0) ? ":" + port : "")); trace.recordRemoteAddr(remoteAddr); trace.recordAttribute(AnnotationKey.HTTP_URL, request.getRequestURI()); } catch (Exception e) { diff --git a/src/test/java/com/profiler/modifier/db/util/JDBCUrlParserTest.java b/src/test/java/com/profiler/modifier/db/util/JDBCUrlParserTest.java index 5bcd3930f..0d658ffb3 100644 --- a/src/test/java/com/profiler/modifier/db/util/JDBCUrlParserTest.java +++ b/src/test/java/com/profiler/modifier/db/util/JDBCUrlParserTest.java @@ -43,8 +43,7 @@ public class JDBCUrlParserTest { DatabaseInfo dbInfo = JDBCUrlParser.parse("jdbc:mysql://ip_address:3306/database_name?useUnicode=yes&characterEncoding=UTF-8"); Assert.assertEquals(dbInfo.getType(), ServiceType.MYSQL); - Assert.assertEquals(dbInfo.getHost(), "ip_address"); - Assert.assertEquals(dbInfo.getPort(), "3306"); + Assert.assertEquals(dbInfo.getHost().get(0), ("ip_address:3306")); Assert.assertEquals(dbInfo.getDatabaseId(), "database_name"); Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://ip_address:3306/database_name"); } @@ -54,19 +53,20 @@ public class JDBCUrlParserTest { DatabaseInfo dbInfo = JDBCUrlParser.parse("jdbc:mysql://10.98.133.22:3306/test_lucy_db"); Assert.assertEquals(dbInfo.getType(), ServiceType.MYSQL); - Assert.assertEquals(dbInfo.getHost(), "10.98.133.22"); - Assert.assertEquals(dbInfo.getPort(), "3306"); + Assert.assertEquals(dbInfo.getHost().get(0), "10.98.133.22:3306"); + Assert.assertEquals(dbInfo.getDatabaseId(), "test_lucy_db"); Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://10.98.133.22:3306/test_lucy_db"); + logger.info(dbInfo.toString()); } @Test public void mysqlParse3() { DatabaseInfo dbInfo = JDBCUrlParser.parse("jdbc:mysql://61.74.71.31/log?useUnicode=yes&characterEncoding=UTF-8"); Assert.assertEquals(dbInfo.getType(), ServiceType.MYSQL); - Assert.assertEquals(dbInfo.getHost(), "61.74.71.31"); - Assert.assertEquals(dbInfo.getPort(), ""); + Assert.assertEquals(dbInfo.getHost().get(0), "61.74.71.31"); Assert.assertEquals(dbInfo.getDatabaseId(), "log"); Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://61.74.71.31/log"); + logger.info(dbInfo.toString()); } }