
enhance.HttpServlet_servicessist Maven / Gradle / Ivy
{
System.out.println("====================增强过的请求++++++++++++++++++++++++++++++");
final String name = String.format("%s %s", new Object[] {$1.getMethod(), $1.getRequestURL()});
System.out.println(name);
//if(name.endsWith(".js") || name.endsWith(".css") || name.endsWith(".jpg") || name.endsWith(".ico")){
// $proceed($$);
//}else{
Span span;
span = SpanHelper.startTrace(name);
final String traceId = $1.getHeader(HttpHeaderNames.TRACE_ID);
final String spanId = $1.getHeader(HttpHeaderNames.SPAN_ID);
if(traceId==null)
{
traceId=String.valueOf(span.getTraceId());
}
if(spanId==null)
{
spanId=String.valueOf(span.getSpanId());
}
org.slf4j.MDC.put("traceId", traceId);
org.slf4j.MDC.put("spanId", spanId);
System.out.println("this is traceId:"+traceId);
if (traceId != null && spanId != null) {
BigInteger traceIdLong = new BigInteger(traceId);
BigInteger spanIdLong = new BigInteger(spanId);
span = SpanHelper.startSpan(traceIdLong, spanIdLong, name);
} else {
span = SpanHelper.startTrace(name);
}
try {
span.addAnnotation(AnnotationNames.SERVER_RECEIVED);
span.addAnnotation(AnnotationNames.SERVICE_NAME, Annotations.getServiceAnnotations().getService());
$proceed($$);
} finally {
span.addAnnotation(AnnotationNames.SERVER_SENT);
span.end();
}
//}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy