mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-22 11:16:25 +10:00
[유치수] [NOBTS] remote addr 수집 기능 추가.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1187 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -21,6 +21,7 @@ public class Span implements Thriftable {
|
||||
private ServiceType serviceType;
|
||||
private String endPoint;
|
||||
private int exception;
|
||||
private String remoteAddr;
|
||||
|
||||
private final List<Annotation> annotations = new ArrayList<Annotation>(5);
|
||||
|
||||
@@ -103,11 +104,19 @@ public class Span implements Thriftable {
|
||||
}
|
||||
|
||||
public void setException(int exception) {
|
||||
this.exception = exception;
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
public String getRemoteAddr() {
|
||||
return remoteAddr;
|
||||
}
|
||||
|
||||
public void setRemoteAddr(String remoteAddr) {
|
||||
this.remoteAddr = remoteAddr;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("{");
|
||||
sb.append("\n\t TraceID = ").append(traceID);
|
||||
@@ -118,6 +127,7 @@ public class Span implements Thriftable {
|
||||
sb.append(", ServiceType = ").append(serviceType);
|
||||
sb.append(", EndPoint = ").append(endPoint);
|
||||
sb.append(", Exception = ").append(exception);
|
||||
sb.append(", RemoteAddr = ").append(remoteAddr);
|
||||
sb.append(",\n\t Annotations = {");
|
||||
for (Annotation a : annotations) {
|
||||
sb.append("\n\t\t").append(a);
|
||||
@@ -145,6 +155,7 @@ public class Span implements Thriftable {
|
||||
span.setSpanId(traceID.getSpanId());
|
||||
span.setParentSpanId(traceID.getParentSpanId());
|
||||
span.setEndPoint(endPoint);
|
||||
span.setRemoteAddr(remoteAddr);
|
||||
if (exception != 0) {
|
||||
span.setErr(exception);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,17 @@ public final class Trace {
|
||||
SubSpan span = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
span.setEndPoint(endPoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void recordRemoteAddr(final String remoteAddr) {
|
||||
// TODO API 단일화 필요.
|
||||
StackFrame currentStackFrame = getCurrentStackFrame();
|
||||
if (currentStackFrame instanceof RootStackFrame) {
|
||||
Span span = ((RootStackFrame) currentStackFrame).getSpan();
|
||||
span.setRemoteAddr(remoteAddr);
|
||||
} else {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
public void recordNextSpanId(int spanId) {
|
||||
|
||||
+4
-3
@@ -41,7 +41,7 @@ public class StandardHostValveInvokeInterceptor implements StaticAroundIntercept
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest) args[0];
|
||||
String requestURL = request.getRequestURI();
|
||||
String clientIP = request.getRemoteAddr();
|
||||
String remoteAddr = request.getRemoteAddr();
|
||||
|
||||
TraceID traceId = populateTraceIdFromRequest(request);
|
||||
Trace trace;
|
||||
@@ -50,7 +50,7 @@ public class StandardHostValveInvokeInterceptor implements StaticAroundIntercept
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
// logger.info("TraceID exist. continue trace. " + nextTraceId);
|
||||
logger.info("TraceID exist. continue trace. " + traceId);
|
||||
logger.log(Level.FINE, "requestUrl:" + requestURL + " clientIp" + clientIP);
|
||||
logger.log(Level.FINE, "requestUrl:" + requestURL + ", remoteAddr:" + remoteAddr);
|
||||
}
|
||||
// trace = new Trace(nextTraceId);
|
||||
trace = new Trace(traceId);
|
||||
@@ -59,7 +59,7 @@ public class StandardHostValveInvokeInterceptor implements StaticAroundIntercept
|
||||
trace = new Trace();
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.info("TraceID not exist. start new trace. " + trace.getTraceId());
|
||||
logger.log(Level.FINE, "requestUrl:" + requestURL + " clientIp" + clientIP);
|
||||
logger.log(Level.FINE, "requestUrl:" + requestURL + ", remoteAddr:" + remoteAddr);
|
||||
}
|
||||
traceContext.attachTraceObject(trace);
|
||||
}
|
||||
@@ -69,6 +69,7 @@ public class StandardHostValveInvokeInterceptor implements StaticAroundIntercept
|
||||
|
||||
int port = request.getServerPort();
|
||||
trace.recordEndPoint(request.getProtocol() + ":" + request.getServerName() + ((port > 0) ? ":" + port : ""));
|
||||
trace.recordRemoteAddr(remoteAddr);
|
||||
trace.recordAttribute(AnnotationNames.HTTP_URL, request.getRequestURI());
|
||||
} catch (Exception e) {
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
|
||||
Reference in New Issue
Block a user