use of com.creditease.uav.apm.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class JdbcDriverAdapter 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);
SlowOperContext slowOperContext = new SlowOperContext();
if (context.get(CaptureConstants.INFO_CLIENT_RESPONSECODE).toString().equals("-1")) {
slowOperContext.put(SlowOperConstants.PROTOCOL_JDBC_RESULT, context.get(CaptureConstants.INFO_CLIENT_RESPONSESTATE));
} else {
Method method = (Method) args[0];
if (method.getName().equals("execute")) {
boolean res = (Boolean) args[1];
if (res) {
Statement statement = (Statement) args[2];
try {
slowOperContext.put(SlowOperConstants.PROTOCOL_JDBC_RESULT, sqlResultSetParse(statement.getResultSet()));
} catch (SQLException e) {
// 由于rc的值即可判断是否有异常,故ignore
}
} else {
Statement statement = (Statement) args[2];
try {
slowOperContext.put(SlowOperConstants.PROTOCOL_JDBC_RESULT, statement.getUpdateCount());
} catch (SQLException e) {
// 由于rc的值即可判断是否有异常,故ignore
}
}
} else if (method.getName().equals("executeBatch")) {
int[] res = (int[]) args[1];
StringBuilder builder = new StringBuilder("[ ");
for (int value : res) {
builder.append(value + " ");
}
builder.append("]");
slowOperContext.put(SlowOperConstants.PROTOCOL_JDBC_RESULT, builder.toString());
} else {
Statement statement = (Statement) args[2];
try {
slowOperContext.put(SlowOperConstants.PROTOCOL_JDBC_RESULT, statement.getUpdateCount());
} catch (Exception e) {
slowOperContext.put(SlowOperConstants.PROTOCOL_JDBC_RESULT, method.getName() + " unsupport!!!");
}
}
}
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 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.slowoper.spi.SlowOperContext 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);
}
}
use of com.creditease.uav.apm.slowoper.spi.SlowOperContext in project uavstack by uavorg.
the class JdbcDriverAdapter method afterPreCap.
@Override
public void afterPreCap(InvokeChainContext context, Object[] args) {
if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
@SuppressWarnings("unchecked") String sql = sqlParse(args[0].toString(), (List<Map<Integer, String>>) args[1]);
SlowOperContext slowOperContext = new SlowOperContext();
slowOperContext.put(SlowOperConstants.PROTOCOL_JDBC_SQL, sql);
String url = (String) context.get(InvokeChainConstants.CLIENT_SPAN_THREADLOCAL_STOREKEY);
Span span = this.spanFactory.getSpanFromContext(url);
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 DubboConsumerAdapter 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);
RpcContext.getContext().setAttachment(InvokeChainConstants.PARAM_RPCHEAD_SPANINFO, spanMeta);
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);
}
}
Aggregations