use of com.creditease.uav.apm.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class DubboConsumerAdapter method afterDoCap.
@Override
public void afterDoCap(InvokeChainContext context, Object[] args) {
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
Span span = (Span) context.get(InvokeChainConstants.PARAM_SPAN_KEY);
if (span == null) {
return;
}
SlowOperContext slowOperContext = new SlowOperContext();
// 根据返回码确定当前是否有异常(由于IT位置已经解析过,此处直接使用)
int respCode = (Integer) context.get(CaptureConstants.INFO_CLIENT_RESPONSECODE);
if (respCode == -1) {
slowOperContext.put(SlowOperConstants.PROTOCOL_METHOD_RETURN, parseReturn(context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE)));
} else {
Result result = (Result) args[2];
slowOperContext.put(SlowOperConstants.PROTOCOL_METHOD_RETURN, parseReturn(result.getValue()));
}
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.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class DubboProviderAdapter 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();
// 根据返回码确定当前是否有异常(由于IT位置已经解析过,此处直接使用)
String respCode = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE);
if (respCode.equals("-1")) {
slowOperContext.put(SlowOperConstants.PROTOCOL_METHOD_RETURN, parseReturn(context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSESTATE)));
} else {
Result result = (Result) args[2];
slowOperContext.put(SlowOperConstants.PROTOCOL_METHOD_RETURN, parseReturn(result.getValue()));
}
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.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class DubboProviderAdapter method afterPreCap.
@Override
public void afterPreCap(InvokeChainContext context, Object[] args) {
String url = (String) context.get(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL);
Span span = this.spanFactory.getSpanFromContext(url);
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
SlowOperContext slowOperContext = new SlowOperContext();
// dubbo虽属于rpc,但从其使用方式上属于方法级
Invocation invocation = (Invocation) args[1];
slowOperContext.put(SlowOperConstants.PROTOCOL_METHOD_PARAMS, parseParams(invocation.getArguments()));
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 RocketMQPushConsumerAdapter 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.CLIENT_SPAN_THREADLOCAL_STOREKEY);
Span span = this.spanFactory.getSpanFromContext(storeKey);
if (span == null) {
return;
}
@SuppressWarnings("unchecked") List<MessageExt> exts = (List<MessageExt>) args[0];
String content;
try {
content = new String(exts.get(0).getBody(), "UTF-8");
} catch (UnsupportedEncodingException e) {
content = "unsupported encoding,defalut is utf-8.try to set ContentEncoding to fit.";
}
SlowOperContext slowOperContext = new SlowOperContext();
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);
}
}
use of com.creditease.uav.apm.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class RabbitmqProducerAdapter method afterPreCap.
@Override
public void afterPreCap(InvokeChainContext context, Object[] args) {
AMQP.BasicProperties props = (BasicProperties) args[0];
Map<String, Object> header = new HashMap<String, Object>();
String storeKey = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY);
Span span = this.spanFactory.getSpanFromContext(storeKey);
String spanMeta = this.spanFactory.getSpanMeta(span);
header.put(InvokeChainConstants.PARAM_MQHEAD_SPANINFO, spanMeta);
if (props == null) {
props = new AMQP.BasicProperties.Builder().headers(header).build();
} else {
if (props.getHeaders() != null) {
header.putAll(props.getHeaders());
}
props = new AMQP.BasicProperties.Builder().appId(props.getAppId()).clusterId(props.getClusterId()).contentEncoding(props.getContentEncoding()).contentType(props.getContentType()).correlationId(props.getCorrelationId()).deliveryMode(props.getDeliveryMode()).expiration(props.getExpiration()).headers(header).messageId(props.getMessageId()).priority(props.getPriority()).replyTo(props.getReplyTo()).timestamp(props.getTimestamp()).type(props.getType()).userId(props.getUserId()).build();
}
context.put(InvokeChainConstants.PARAM_MQHEAD_INFO, props);
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
byte[] body = (byte[]) args[1];
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);
}
Object[] params = { span, slowOperContext };
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap", span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.PRECAP, context, params);
}
}
Aggregations