use of com.creditease.uav.apm.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class RabbitmqConsumerAdapter method afterPreCap.
@Override
public void afterPreCap(InvokeChainContext context, Object[] args) {
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
AMQP.BasicProperties props = (BasicProperties) args[2];
byte[] body = (byte[]) args[3];
SlowOperContext slowOperContext = new SlowOperContext();
if (props == null || StringHelper.isEmpty(props.getContentEncoding())) {
String content = "";
try {
content = new String(body, "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);
} else {
String encoding = props.getContentEncoding();
String content = "";
try {
content = new String(body, encoding);
} catch (UnsupportedEncodingException e) {
content = "ContentEncoding is " + encoding + " .but content is unsupported this encoding.";
}
slowOperContext.put(SlowOperConstants.PROTOCOL_MQ_RABBIT_BODY, content);
}
String url = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL);
Span span = this.spanFactory.getSpanFromContext(url);
if (span == null || span.getEndpointInfo() == null) {
if (logger.isDebugable()) {
logger.debug("Span of context is null, url=" + url, null);
}
return;
}
Object[] params = { span, slowOperContext };
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.PRECAP, context, params);
}
}
use of com.creditease.uav.apm.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class MethodSpanAdapter method afterDoCap.
@Override
public void afterDoCap(InvokeChainContext context, Object[] args) {
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
String storekey = (String) context.get(InvokeChainConstants.METHOD_SPAN_STOREKEY);
if (storekey == null) {
return;
}
Span span = (Span) context.get(storekey);
if (span == null) {
return;
}
SlowOperContext slowOperContext = new SlowOperContext();
slowOperContext.put(SlowOperConstants.PROTOCOL_METHOD_RETURN, parseReturn(args));
Object[] params = { span, slowOperContext };
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", SlowOperConstants.SLOW_OPER_METHOD, InvokeChainConstants.CapturePhase.DOCAP, context, params);
}
}
use of com.creditease.uav.apm.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class MethodSpanAdapter method afterPreCap.
@Override
public void afterPreCap(InvokeChainContext context, Object[] args) {
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
String storekey = (String) context.get(InvokeChainConstants.METHOD_SPAN_STOREKEY);
Span span = (Span) context.get(storekey);
SlowOperContext slowOperContext = new SlowOperContext();
slowOperContext.put(SlowOperConstants.PROTOCOL_METHOD_PARAMS, parseParams(args));
Object[] params = { span, slowOperContext };
// 由于使用Endpoint Info不能区分方法级,故此处使用常量
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", SlowOperConstants.SLOW_OPER_METHOD, InvokeChainConstants.CapturePhase.PRECAP, context, params);
}
}
use of com.creditease.uav.apm.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class ServerSpanAdapter method afterPreCap.
@Override
public void afterPreCap(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.getSpanFromContext(url);
SlowOperContext slowOperContext = new SlowOperContext();
HttpServletRequest request = (HttpServletRequest) args[0];
// 由于会存在没有拦截住的情况,但当前无论拦截与未拦截的情况均可以使用HttpServletRequest获取header,故此处预留出来
// if (RewriteIvcRequestWrapper.class.isAssignableFrom(args[0].getClass())) {
// }
// else {
//
// }
// 当前将所有header信息打印出来,后续可能只打印用户自定义的将UAV的header过滤
// 提取参数并放入header里
String parameters = JSONHelper.toString(request.getParameterMap());
if (parameters == null) {
parameters = "{}";
}
slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_REQ_HEADER, getRequestHeaders(request) + parameters);
Object[] params = { span, slowOperContext };
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.PRECAP, context, params);
}
}
use of com.creditease.uav.apm.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class AbstractSlowOperHandler method preCap.
@Override
public void preCap(InvokeChainContext context, Object[] args) {
Span span = (Span) args[0];
SlowOperSpan slowOperSpan = this.spanFactory.buildSlowOperSpan(span);
SlowOperContext slowOperContext = (SlowOperContext) args[1];
buildSpanContent(slowOperContext, slowOperSpan);
this.spanFactory.setSlowOperSpanToContext(this.getSlowOperSpanKey(span), slowOperSpan);
}
Aggregations