提交 3eeacb1a 编写于 作者: L lytscu

Update comments

上级 59380c46
...@@ -32,7 +32,8 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt ...@@ -32,7 +32,8 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
/** /**
* {org.apache.skywalking.apm.plugin.servicecomb.} define how to enhance class {@link Invocation#getHandlerContext()}. * {org.apache.skywalking.apm.plugin.servicecomb.ProducerOperationHandlerInterceptor} define how to enhance class {@link
* ProducerOperationHandler#handle(io.servicecomb.core.Invocation, io.servicecomb.swagger.invocation.AsyncResponse)}.
* *
* @author lytscu * @author lytscu
*/ */
...@@ -48,10 +49,7 @@ public class ProducerOperationHandlerInterceptor implements InstanceMethodsAroun ...@@ -48,10 +49,7 @@ public class ProducerOperationHandlerInterceptor implements InstanceMethodsAroun
next = next.next(); next = next.next();
next.setHeadValue(invocation.getContext().get(next.getHeadKey())); next.setHeadValue(invocation.getContext().get(next.getHeadKey()));
} }
String operationName = "servicecomb/chassis" + method.getName(); String operationName = invocation.getMicroserviceQualifiedName();
if (null != invocation.getOperationMeta()) {
operationName = invocation.getMicroserviceQualifiedName();
}
AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier); AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);
String url = invocation.getOperationMeta().getOperationPath(); String url = invocation.getOperationMeta().getOperationPath();
Tags.URL.set(span, url); Tags.URL.set(span, url);
......
...@@ -21,7 +21,6 @@ package org.apache.skywalking.apm.plugin.servicecomb; ...@@ -21,7 +21,6 @@ package org.apache.skywalking.apm.plugin.servicecomb;
import io.servicecomb.core.Invocation; import io.servicecomb.core.Invocation;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
import org.apache.skywalking.apm.agent.core.context.CarrierItem; import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier; import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager; import org.apache.skywalking.apm.agent.core.context.ContextManager;
...@@ -34,7 +33,8 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt ...@@ -34,7 +33,8 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
/** /**
* {@link TransportClientHandlerInterceptor} define how to enhance class {@link Invocation#next(io.servicecomb.swagger.invocation.AsyncResponse)}. * {@link TransportClientHandlerInterceptor} define how to enhance class {@link TransportClientHandler#handle(io.servicecomb.core.Invocation,
* io.servicecomb.swagger.invocation.AsyncResponse)}.
* *
* @author lytscu * @author lytscu
*/ */
...@@ -44,10 +44,11 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI ...@@ -44,10 +44,11 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Invocation invocation = (Invocation)allArguments[0]; Invocation invocation = (Invocation)allArguments[0];
String peer = AsserRegister(invocation); if (!checkRegisterStatus(invocation)) {
if (null == peer) {
return; return;
} }
URI uri = new URI(invocation.getEndpoint().toString());
String peer = uri.getHost() + ":" + uri.getPort();
String operationName = invocation.getMicroserviceQualifiedName(); String operationName = invocation.getMicroserviceQualifiedName();
final ContextCarrier contextCarrier = new ContextCarrier(); final ContextCarrier contextCarrier = new ContextCarrier();
AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, peer); AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, peer);
...@@ -65,8 +66,7 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI ...@@ -65,8 +66,7 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI
@Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Object ret) throws Throwable { Class<?>[] argumentsTypes, Object ret) throws Throwable {
Invocation invocation = (Invocation)allArguments[0]; Invocation invocation = (Invocation)allArguments[0];
String peer = AsserRegister(invocation); if (!checkRegisterStatus(invocation)) {
if (null == peer) {
return ret; return ret;
} }
AbstractSpan span = ContextManager.activeSpan(); AbstractSpan span = ContextManager.activeSpan();
...@@ -82,7 +82,7 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI ...@@ -82,7 +82,7 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) { Class<?>[] argumentsTypes, Throwable t) {
Invocation invocation = (Invocation)allArguments[0]; Invocation invocation = (Invocation)allArguments[0];
if (null == invocation.getOperationMeta() || null == invocation.getEndpoint()) { if (!checkRegisterStatus(invocation)) {
return; return;
} }
AbstractSpan span = ContextManager.activeSpan(); AbstractSpan span = ContextManager.activeSpan();
...@@ -91,16 +91,14 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI ...@@ -91,16 +91,14 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI
} }
/** /**
* Serviecomb chissis Consumers and providers need to register at the service center. If the consumer is not * Serviecomb chassis Consumers and providers need to register at the service center. If the consumer is not
* registered then return * registered then return false.
*/ */
private String AsserRegister(Invocation invocation) throws URISyntaxException { private Boolean checkRegisterStatus(Invocation invocation) {
if (null == invocation.getOperationMeta() || null == invocation.getEndpoint()) { if (null == invocation.getOperationMeta() || null == invocation.getEndpoint()) {
return null; return false;
} }
URI uri = new URI(invocation.getEndpoint().toString()); return true;
String peer = uri.getHost() + ":" + uri.getPort();
return peer;
} }
} }
...@@ -29,8 +29,8 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; ...@@ -29,8 +29,8 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.named;
/** /**
* {@link ProducerOperationHandlerInstrumentation} presents that skywalking intercept {@link * {@link ProducerOperationHandlerInstrumentation} represents that skywalking intercept {@link
* ProducerOperationHandler#handle (io.servicecomb.core.Invocation, io.servicecomb.swagger.invocation.AsyncResponse)#}by * ProducerOperationHandler#handle(io.servicecomb.core.Invocation, io.servicecomb.swagger.invocation.AsyncResponse)}by
* using {@link ProducerOperationHandlerInterceptor} * using {@link ProducerOperationHandlerInterceptor}
* *
* @author lytscu * @author lytscu
......
...@@ -30,7 +30,7 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; ...@@ -30,7 +30,7 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.named;
/** /**
* {@link TransportClientHandlerInstrumentation} presents that skywalking intercept {@link TransportClientHandler}by * {@link TransportClientHandlerInstrumentation} represents that skywalking intercept {@link TransportClientHandler}by
* using {@linkTransportClientHandlerInterceptor } * using {@linkTransportClientHandlerInterceptor }
* *
* @author lytscu * @author lytscu
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册