Update exception status

This commit is contained in:
lytscu 2018-02-11 14:57:42 +08:00
parent e233b7becc
commit 2e95e7fff2
2 changed files with 19 additions and 3 deletions

View File

@ -48,16 +48,28 @@ public class ProducerOperationHandlerInterceptor implements InstanceMethodsAroun
next = next.next();
next.setHeadValue(invocation.getContext().get(next.getHeadKey()));
}
if (null == invocation.getOperationMeta()) {
return;
}
String operationName = invocation.getMicroserviceQualifiedName();
AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);
String url = invocation.getOperationMeta().getOperationPath();
Tags.URL.set(span, url);
if (null != invocation.getOperationMeta() && null != invocation.getOperationMeta().getOperationPath()) {
String url = invocation.getOperationMeta().getOperationPath();
Tags.URL.set(span, url);
}
span.setComponent(ComponentsDefine.SERVICECOMB);
SpanLayer.asRPCFramework(span);
}
@Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Object ret) throws Throwable {
Invocation invocation = (Invocation)allArguments[0];
AbstractSpan span = ContextManager.activeSpan();
int statusCode = invocation.getStatus().getStatusCode();
if (statusCode >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
}
ContextManager.stopSpan();
return ret;
}

View File

@ -43,10 +43,14 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Invocation invocation = (Invocation)allArguments[0];
if (null == invocation.getOperationMeta() || null == invocation.getEndpoint()) {
return;
}
URI uri = new URI(invocation.getEndpoint().toString());
String peer = uri.getHost() + ":" + uri.getPort();
String operationName = invocation.getMicroserviceQualifiedName();
final ContextCarrier contextCarrier = new ContextCarrier();
AbstractSpan span = ContextManager.createExitSpan(invocation.getMicroserviceQualifiedName(), contextCarrier, peer);
AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, peer);
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();