From 3eeacb1ae6fc6c8fe06fe2f898fdb65287c23e24 Mon Sep 17 00:00:00 2001 From: lytscu Date: Mon, 12 Feb 2018 15:23:44 +0800 Subject: [PATCH] Update comments --- .../ProducerOperationHandlerInterceptor.java | 8 +++--- .../TransportClientHandlerInterceptor.java | 26 +++++++++---------- ...oducerOperationHandlerInstrumentation.java | 4 +-- ...TransportClientHandlerInstrumentation.java | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/ProducerOperationHandlerInterceptor.java b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/ProducerOperationHandlerInterceptor.java index 56ce3a2ce2..4c0e97840e 100644 --- a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/ProducerOperationHandlerInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/ProducerOperationHandlerInterceptor.java @@ -32,7 +32,8 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt 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 */ @@ -48,10 +49,7 @@ public class ProducerOperationHandlerInterceptor implements InstanceMethodsAroun next = next.next(); next.setHeadValue(invocation.getContext().get(next.getHeadKey())); } - String operationName = "servicecomb/chassis" + method.getName(); - if (null != invocation.getOperationMeta()) { - operationName = invocation.getMicroserviceQualifiedName(); - } + String operationName = invocation.getMicroserviceQualifiedName(); AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier); String url = invocation.getOperationMeta().getOperationPath(); Tags.URL.set(span, url); diff --git a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/TransportClientHandlerInterceptor.java b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/TransportClientHandlerInterceptor.java index 10f39a814f..c3d40d3395 100644 --- a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/TransportClientHandlerInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/TransportClientHandlerInterceptor.java @@ -21,7 +21,6 @@ package org.apache.skywalking.apm.plugin.servicecomb; import io.servicecomb.core.Invocation; import java.lang.reflect.Method; 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.ContextCarrier; import org.apache.skywalking.apm.agent.core.context.ContextManager; @@ -34,7 +33,8 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt 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 */ @@ -44,10 +44,11 @@ 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]; - String peer = AsserRegister(invocation); - if (null == peer) { + if (!checkRegisterStatus(invocation)) { 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(operationName, contextCarrier, peer); @@ -65,8 +66,7 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Object ret) throws Throwable { Invocation invocation = (Invocation)allArguments[0]; - String peer = AsserRegister(invocation); - if (null == peer) { + if (!checkRegisterStatus(invocation)) { return ret; } AbstractSpan span = ContextManager.activeSpan(); @@ -82,7 +82,7 @@ public class TransportClientHandlerInterceptor implements InstanceMethodsAroundI @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Throwable t) { Invocation invocation = (Invocation)allArguments[0]; - if (null == invocation.getOperationMeta() || null == invocation.getEndpoint()) { + if (!checkRegisterStatus(invocation)) { return; } AbstractSpan span = ContextManager.activeSpan(); @@ -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 - * registered then return + * Serviecomb chassis Consumers and providers need to register at the service center. If the consumer is not + * registered then return false. */ - private String AsserRegister(Invocation invocation) throws URISyntaxException { + private Boolean checkRegisterStatus(Invocation invocation) { if (null == invocation.getOperationMeta() || null == invocation.getEndpoint()) { - return null; + return false; } - URI uri = new URI(invocation.getEndpoint().toString()); - String peer = uri.getHost() + ":" + uri.getPort(); - return peer; + return true; } } diff --git a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/define/ProducerOperationHandlerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/define/ProducerOperationHandlerInstrumentation.java index e160b8d42a..3151782b89 100644 --- a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/define/ProducerOperationHandlerInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/define/ProducerOperationHandlerInstrumentation.java @@ -29,8 +29,8 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link ProducerOperationHandlerInstrumentation} presents that skywalking intercept {@link - * ProducerOperationHandler#handle (io.servicecomb.core.Invocation, io.servicecomb.swagger.invocation.AsyncResponse)#}by + * {@link ProducerOperationHandlerInstrumentation} represents that skywalking intercept {@link + * ProducerOperationHandler#handle(io.servicecomb.core.Invocation, io.servicecomb.swagger.invocation.AsyncResponse)}by * using {@link ProducerOperationHandlerInterceptor} * * @author lytscu diff --git a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/define/TransportClientHandlerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/define/TransportClientHandlerInstrumentation.java index 2c644fe692..5c0848243d 100644 --- a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/define/TransportClientHandlerInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/define/TransportClientHandlerInstrumentation.java @@ -30,7 +30,7 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; 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 } * * @author lytscu -- GitLab