use of com.creditease.uav.apm.invokechain.span.Span in project uavstack by uavorg.
the class ServerSpanAdapter method afterDoCap.
@Override
public void afterDoCap(InvokeChainContext context, Object[] args) {
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
String url = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL);
Span span = this.spanFactory.getRemoveSpanFromContext(url);
if (span == null) {
return;
}
SlowOperContext slowOperContext = new SlowOperContext();
// 防止有没有拦截住的请求
if (RewriteIvcRequestWrapper.class.isAssignableFrom(args[0].getClass()) && RewriteIvcResponseWrapper.class.isAssignableFrom(args[1].getClass())) {
RewriteIvcRequestWrapper request = (RewriteIvcRequestWrapper) args[0];
slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_REQ_BODY, request.getContent().toString());
request.clearBodyContent();
RewriteIvcResponseWrapper response = (RewriteIvcResponseWrapper) args[1];
slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_RSP_HEADER, getResponHeaders(response));
slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_RSP_BODY, response.getContent().toString());
response.clearBodyContent();
} else {
slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_REQ_BODY, "unsupported request");
HttpServletResponse response = (HttpServletResponse) args[1];
slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_RSP_HEADER, getResponHeaders(response));
slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_RSP_BODY, "unsupported response");
}
Object[] params = { span, slowOperContext };
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.DOCAP, context, params);
}
}
use of com.creditease.uav.apm.invokechain.span.Span in project uavstack by uavorg.
the class MQSlowOperHandler method doCap.
@Override
public void doCap(InvokeChainContext context, Object[] args) {
Span span = (Span) args[0];
DataLogger invokeChainLogger = this.getAppInvokeChainLogger(span.getAppid());
if (invokeChainLogger == null) {
return;
}
SlowOperSpan slowOperSpan = this.spanFactory.getRemoveSlowOperSpanFromContext(this.getSlowOperSpanKey(span));
if (slowOperSpan == null) {
return;
}
invokeChainLogger.logData(slowOperSpan.toString());
}
use of com.creditease.uav.apm.invokechain.span.Span in project uavstack by uavorg.
the class ApacheAsyncHttpClientAdapter method afterPreCap.
@Override
public void afterPreCap(InvokeChainContext context, Object[] args) {
HttpAsyncRequestProducer requestProducer = null;
HttpRequest request = null;
if (args.length == 4) {
requestProducer = (HttpAsyncRequestProducer) args[0];
} else if (args.length == 5) {
requestProducer = (HttpAsyncRequestProducer) args[1];
} else {
return;
}
try {
request = requestProducer.generateRequest();
} catch (Exception e) {
// ignore
}
if (request == null) {
return;
}
/**
* after precap the client's span is created, set the span meta into http request header
*/
String url = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY);
Span span = this.spanFactory.getSpanFromContext(url);
String spanMeta = this.spanFactory.getSpanMeta(span);
request.removeHeaders(InvokeChainConstants.PARAM_HTTPHEAD_SPANINFO);
request.addHeader(InvokeChainConstants.PARAM_HTTPHEAD_SPANINFO, spanMeta);
/**
* store span into context for async
*/
context.put(InvokeChainConstants.PARAM_SPAN_KEY, span);
handleSlowOperSupporter(request, span, context);
}
use of com.creditease.uav.apm.invokechain.span.Span in project uavstack by uavorg.
the class JaxWSAdapter method afterPreCap.
@Override
public void afterPreCap(InvokeChainContext context, Object[] args) {
String url = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY);
Span span = this.spanFactory.getSpanFromContext(url);
String spanMeta = this.spanFactory.getSpanMeta(span);
List<String> spanValue = new ArrayList<String>(1);
spanValue.add(spanMeta);
Map<String, List<String>> header = new HashMap<String, List<String>>(1);
header.put(InvokeChainConstants.PARAM_HTTPHEAD_SPANINFO, spanValue);
String method = (String) context.get(CaptureConstants.INFO_CLIENT_REQUEST_ACTION);
List<String> methodValue = new ArrayList<String>(1);
methodValue.add(method);
header.put(InvokeChainConstants.CLIENT_IT_METHOD, methodValue);
context.put(InvokeChainConstants.PARAM_HTTPHEAD_SPANINFO, header);
}
use of com.creditease.uav.apm.invokechain.span.Span in project uavstack by uavorg.
the class RocketMQProducerAdapter method afterPreCap.
@Override
public void afterPreCap(InvokeChainContext context, Object[] args) {
String storeKey = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY);
Span span = this.spanFactory.getSpanFromContext(storeKey);
String spanMeta = this.spanFactory.getSpanMeta(span);
Message msg = (Message) args[0];
msg.putUserProperty(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, spanMeta);
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
SlowOperContext slowOperContext = new SlowOperContext();
String content;
try {
content = new String(msg.getBody(), "UTF-8");
} catch (UnsupportedEncodingException e) {
content = "unsupported encoding,defalut is utf-8.try to set ContentEncoding to fit.";
}
slowOperContext.put(SlowOperConstants.PROTOCOL_MQ_RABBIT_BODY, content);
Object[] params = { span, slowOperContext };
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.PRECAP, context, params);
}
}
Aggregations