diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallIConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/AbstractCallClientInterceptor.java
similarity index 51%
rename from apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallIConstructorInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/AbstractCallClientInterceptor.java
index 1444ea840..93e8e2c41 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallIConstructorInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/AbstractCallClientInterceptor.java
@@ -16,26 +16,24 @@
*
*/
-
package org.apache.skywalking.apm.plugin.grpc.v1;
+import io.grpc.Channel;
+import io.grpc.ClientCall;
+import io.grpc.ForwardingClientCall;
import io.grpc.MethodDescriptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-/**
- * {@link ClientCallIConstructorInterceptor} pass the {@link GRPCDynamicFields} into the
- * io.grpc.internal.ClientCallImpl instance for propagate the information of build span.
- *
- * @author zhangxin
- */
-public class ClientCallIConstructorInterceptor implements InstanceConstructorInterceptor {
+import static org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil.formatOperationName;
- @Override
- public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
- GRPCDynamicFields dynamicFields = new GRPCDynamicFields();
- dynamicFields.setDescriptor((MethodDescriptor)allArguments[0]);
- objInst.setSkyWalkingDynamicField(dynamicFields);
+public abstract class AbstractCallClientInterceptor extends ForwardingClientCall.SimpleForwardingClientCall {
+
+ protected final String serviceName;
+ protected final String remotePeer;
+
+ protected AbstractCallClientInterceptor(ClientCall delegate, MethodDescriptor method, Channel channel) {
+ super(delegate);
+ this.serviceName = formatOperationName(method);
+ this.remotePeer = channel.authority();
}
+
}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ManagedChannelInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/AbstractServerImplBuilderInterceptor.java
similarity index 75%
rename from apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ManagedChannelInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/AbstractServerImplBuilderInterceptor.java
index 34f42f18e..cf4c81004 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ManagedChannelInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/AbstractServerImplBuilderInterceptor.java
@@ -16,37 +16,30 @@
*
*/
-
package org.apache.skywalking.apm.plugin.grpc.v1;
-import io.grpc.internal.ManagedChannelImpl;
+import io.grpc.ServerInterceptors;
+import io.grpc.ServerServiceDefinition;
import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-/**
- * {@link ManagedChannelInterceptor} record the IP address of the GRPC server into {@link GRPCDynamicFields} for build
- * span.
- *
- * @author zhangxin
- */
-public class ManagedChannelInterceptor implements InstanceMethodsAroundInterceptor {
+public class AbstractServerImplBuilderInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
+ allArguments[0] = ServerInterceptors.intercept((ServerServiceDefinition)allArguments[0], new CallServerInterceptor());
}
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
Object ret) throws Throwable {
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)((EnhancedInstance)ret).getSkyWalkingDynamicField();
- cachedObjects.setAuthority(((ManagedChannelImpl)((Object)objInst)).authority());
return ret;
}
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class>[] argumentsTypes, Throwable t) {
+
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnCancelInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/AbstractStubInterceptor.java
similarity index 67%
rename from apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnCancelInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/AbstractStubInterceptor.java
index 26d2176a0..f1c6ae6e9 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnCancelInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/AbstractStubInterceptor.java
@@ -16,24 +16,22 @@
*
*/
-
package org.apache.skywalking.apm.plugin.grpc.v1;
+import io.grpc.Channel;
+import io.grpc.ClientInterceptors;
import java.lang.reflect.Method;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.plugin.grpc.v1.define.Constants;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-/**
- * {@link ServerCallOnCancelInterceptor} stop the active span when the call cancelled.
- *
- * @author zhangxin
- */
-public class ServerCallOnCancelInterceptor implements InstanceMethodsAroundInterceptor {
+public class AbstractStubInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor {
+ @Override
+ public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+ Channel channel = (Channel)allArguments[0];
+ objInst.setSkyWalkingDynamicField(ClientInterceptors.intercept(channel, new GRPCClientInterceptor()));
+ }
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
@@ -43,15 +41,10 @@ public class ServerCallOnCancelInterceptor implements InstanceMethodsAroundInter
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
Object ret) throws Throwable {
- AbstractSpan abstractSpan = ContextManager.activeSpan();
- abstractSpan.tag(Constants.ON_NEXT_COUNT_TAG_KEY, String.valueOf(((GRPCDynamicFields)objInst.getSkyWalkingDynamicField()).getOnNextCount()));
-
- ContextManager.stopSpan();
- return ret;
+ return objInst.getSkyWalkingDynamicField();
}
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class>[] argumentsTypes, Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/BlockingCallClientInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/BlockingCallClientInterceptor.java
new file mode 100644
index 000000000..16bc0f949
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/BlockingCallClientInterceptor.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.grpc.v1;
+
+import io.grpc.Channel;
+import io.grpc.ClientCall;
+import io.grpc.ForwardingClientCallListener;
+import io.grpc.Metadata;
+import io.grpc.MethodDescriptor;
+import io.grpc.Status;
+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;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+public class BlockingCallClientInterceptor extends AbstractCallClientInterceptor {
+
+ public BlockingCallClientInterceptor(ClientCall delegate, MethodDescriptor method, Channel channel) {
+ super(delegate, method, channel);
+ }
+
+ @Override public void start(Listener responseListener, Metadata headers) {
+ final AbstractSpan span = ContextManager.createExitSpan(serviceName, remotePeer);
+ span.setComponent(ComponentsDefine.GRPC);
+ SpanLayer.asRPCFramework(span);
+ final ContextCarrier contextCarrier = new ContextCarrier();
+ ContextManager.inject(contextCarrier);
+ CarrierItem contextItem = contextCarrier.items();
+ while (contextItem.hasNext()) {
+ contextItem = contextItem.next();
+ Metadata.Key headerKey = Metadata.Key.of(contextItem.getHeadKey(), Metadata.ASCII_STRING_MARSHALLER);
+ headers.put(headerKey, contextItem.getHeadValue());
+ }
+ delegate().start(new CallListener(responseListener), headers);
+ }
+
+ private class CallListener extends ForwardingClientCallListener.SimpleForwardingClientCallListener {
+ protected CallListener(Listener delegate) {
+ super(delegate);
+ }
+
+ @Override public void onReady() {
+ delegate().onReady();
+ }
+
+ @Override public void onClose(Status status, Metadata trailers) {
+ delegate().onClose(status, trailers);
+ if (status.isOk()) {
+ AbstractSpan activeSpan = ContextManager.activeSpan();
+ activeSpan.errorOccurred().log(status.getCause());
+ Tags.STATUS_CODE.set(activeSpan, status.getCode().name());
+ }
+ ContextManager.stopSpan();
+ }
+
+ @Override
+ public void onMessage(Object message) {
+ delegate().onMessage(message);
+ }
+
+ @Override public void onHeaders(Metadata headers) {
+ delegate().onHeaders(headers);
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnReadyInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/CallServerInterceptor.java
similarity index 53%
rename from apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnReadyInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/CallServerInterceptor.java
index e849e40b9..ecff56a31 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnReadyInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/CallServerInterceptor.java
@@ -16,41 +16,29 @@
*
*/
-
package org.apache.skywalking.apm.plugin.grpc.v1;
+import io.grpc.ForwardingServerCall;
+import io.grpc.ForwardingServerCallListener;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
-import java.lang.reflect.Method;
+import io.grpc.ServerCall;
+import io.grpc.ServerCallHandler;
+import io.grpc.ServerInterceptor;
import java.util.HashMap;
import java.util.Map;
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;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
import org.apache.skywalking.apm.util.StringUtil;
-import static org.apache.skywalking.apm.plugin.grpc.v1.define.Constants.STREAM_CALL_OPERATION_NAME_SUFFIX;
-import static org.apache.skywalking.apm.plugin.grpc.v1.define.Constants.BLOCK_CALL_OPERATION_NAME_SUFFIX;
-
-/**
- * {@link ServerCallOnReadyInterceptor} create a entry span when the server side is ready for receive the message from
- * the client side.
- *
- * @author zhangxin
- */
-public class ServerCallOnReadyInterceptor implements InstanceMethodsAroundInterceptor {
+import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.STREAM_ON_NEXT_OPERATION_NAME;
+public class CallServerInterceptor implements ServerInterceptor {
@Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)objInst.getSkyWalkingDynamicField();
- Metadata headers = cachedObjects.getMetadata();
+ public ServerCall.Listener interceptCall(ServerCall call, Metadata headers, ServerCallHandler handler) {
Map headerMap = new HashMap();
for (String key : headers.keys()) {
if (!key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) {
@@ -69,18 +57,51 @@ public class ServerCallOnReadyInterceptor implements InstanceMethodsAroundInterc
}
}
- final AbstractSpan span = ContextManager.createEntrySpan(cachedObjects.getRequestMethodName() + (cachedObjects.getMethodType() != MethodDescriptor.MethodType.UNARY ? STREAM_CALL_OPERATION_NAME_SUFFIX : BLOCK_CALL_OPERATION_NAME_SUFFIX), contextCarrier);
+ final AbstractSpan span = ContextManager.createEntrySpan(call.getMethodDescriptor().getFullMethodName(), contextCarrier);
span.setComponent(ComponentsDefine.GRPC);
+
+ return new ServerCallListener(handler.startCall(new ForwardingServerCall.SimpleForwardingServerCall(call) {
+ @Override
+ public void sendHeaders(Metadata responseHeaders) {
+ delegate().sendHeaders(responseHeaders);
+ }
+ }, headers), call.getMethodDescriptor());
}
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- return ret;
+ public class ServerCallListener extends ForwardingServerCallListener.SimpleForwardingServerCallListener {
+
+ protected ServerCallListener(ServerCall.Listener delegate, MethodDescriptor descriptor) {
+ super(delegate);
+ }
+
+ @Override public void onReady() {
+ delegate().onReady();
+ }
+
+ @Override public void onMessage(Object message) {
+ try {
+ ContextManager.createLocalSpan(STREAM_ON_NEXT_OPERATION_NAME);
+ delegate().onMessage(message);
+ } catch (Throwable t) {
+ ContextManager.activeSpan().errorOccurred().log(t);
+ } finally {
+ ContextManager.stopSpan();
+ }
+ }
+
+ @Override public void onComplete() {
+ delegate().onComplete();
+ ContextManager.stopSpan();
+ }
+
+ @Override public void onCancel() {
+ delegate().onCancel();
+ ContextManager.stopSpan();
+ }
+
+ @Override public void onHalfClose() {
+ delegate().onHalfClose();
+ }
}
- @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
- }
}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallOnNextInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallOnNextInterceptor.java
deleted file mode 100644
index f0901634b..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallOnNextInterceptor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1;
-
-import java.lang.reflect.Method;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.plugin.grpc.v1.define.Constants;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-
-/**
- * {@link ClientCallOnNextInterceptor} create a local span when the client stream receive an message that send from
- * server stream and record the value of OnNext.count tag.
- *
- * @author zhangxin
- */
-public class ClientCallOnNextInterceptor implements InstanceMethodsAroundInterceptor {
-
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)objInst.getSkyWalkingDynamicField();
- ContextManager.createLocalSpan(cachedObjects.getRequestMethodName() + Constants.STREAM_OPERATION_NAME_SUFFIX);
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- ContextManager.stopSpan();
-
- // record the call count of onNext method
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)objInst.getSkyWalkingDynamicField();
- cachedObjects.incrementOnNextCount();
-
- return ret;
- }
-
- @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallStartInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallStartInterceptor.java
deleted file mode 100644
index f478bcee6..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallStartInterceptor.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1;
-
-import io.grpc.Metadata;
-import java.lang.reflect.Method;
-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;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-
-public class ClientCallStartInterceptor implements InstanceMethodsAroundInterceptor {
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- final Metadata headers = (Metadata)allArguments[1];
-
- final ContextCarrier contextCarrier = new ContextCarrier();
- ContextManager.inject(contextCarrier);
- CarrierItem contextItem = contextCarrier.items();
- while (contextItem.hasNext()) {
- contextItem = contextItem.next();
- Metadata.Key headerKey = Metadata.Key.of(contextItem.getHeadKey(), Metadata.ASCII_STRING_MARSHALLER);
- headers.put(headerKey, contextItem.getHeadValue());
- }
-
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)objInst.getSkyWalkingDynamicField();
- GRPCDynamicFields listenerCachedObject = new GRPCDynamicFields();
- listenerCachedObject.setSnapshot(ContextManager.capture());
- listenerCachedObject.setDescriptor(cachedObjects.getDescriptor());
- ((EnhancedInstance)allArguments[0]).setSkyWalkingDynamicField(listenerCachedObject);
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- return ret;
- }
-
- @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
-
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallsMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallsMethodInterceptor.java
deleted file mode 100644
index ecb536b9e..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ClientCallsMethodInterceptor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1;
-
-import java.lang.reflect.Method;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-
-/**
- * {@link ClientCallOnNextInterceptor} create a exist span when the grpc start call. it will stop span when the method
- * type is non-unary.
- *
- * @author zhangxin
- */
-public class ClientCallsMethodInterceptor
- implements StaticMethodsAroundInterceptor {
-
- @Override public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class>[] parameterTypes,
- MethodInterceptResult result) {
- EnhancedInstance clientCall = (EnhancedInstance)allArguments[0];
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)clientCall.getSkyWalkingDynamicField();
-
- final AbstractSpan span = ContextManager.createExitSpan(cachedObjects.getRequestMethodName(), cachedObjects.getAuthority());
- span.setComponent(ComponentsDefine.GRPC);
- SpanLayer.asRPCFramework(span);
- }
-
- @Override public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class>[] parameterTypes,
- Object ret) {
- ContextManager.stopSpan();
- return ret;
- }
-
- @Override
- public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class>[] parameterTypes,
- Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/Constants.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/Constants.java
similarity index 64%
rename from apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/Constants.java
rename to apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/Constants.java
index eb1da7d28..cf3af11e2 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/Constants.java
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/Constants.java
@@ -16,22 +16,10 @@
*
*/
+package org.apache.skywalking.apm.plugin.grpc.v1;
-package org.apache.skywalking.apm.plugin.grpc.v1.define;
-
-/**
- * GRPC Plugin constants variables.
- *
- * @author zhangxin
- */
-public final class Constants {
-
- public static final String STREAM_OPERATION_NAME_SUFFIX = "/ResponseStreamObserver/OnNext";
-
- public static final String ON_NEXT_COUNT_TAG_KEY = "onNext.count";
-
- public static final String STREAM_CALL_OPERATION_NAME_SUFFIX = "/StreamCall";
-
- public static final String BLOCK_CALL_OPERATION_NAME_SUFFIX = "/BlockCall";
+public class Constants {
+ public static final String STREAM_ON_READY_OPERATION_NAME = "RequestStreamObserver/onReady";
+ public static final String STREAM_ON_NEXT_OPERATION_NAME = "ResponseStreamObserver/OnNext";
}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/UnaryStreamToFutureConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/GRPCClientInterceptor.java
similarity index 58%
rename from apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/UnaryStreamToFutureConstructorInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/GRPCClientInterceptor.java
index 0efca9ff8..e62cd40d8 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/UnaryStreamToFutureConstructorInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/GRPCClientInterceptor.java
@@ -16,20 +16,22 @@
*
*/
-
package org.apache.skywalking.apm.plugin.grpc.v1;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import io.grpc.CallOptions;
+import io.grpc.Channel;
+import io.grpc.ClientCall;
+import io.grpc.ClientInterceptor;
+import io.grpc.MethodDescriptor;
-/**
- * {@link UnaryStreamToFutureConstructorInterceptor} stop the active span when the call end.
- *
- * @author zhangxin
- */
-public class UnaryStreamToFutureConstructorInterceptor implements InstanceConstructorInterceptor {
-
- @Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+public class GRPCClientInterceptor implements ClientInterceptor {
+ @Override public ClientCall interceptCall(MethodDescriptor method,
+ CallOptions callOptions, Channel channel) {
+ if (method.getType() != MethodDescriptor.MethodType.UNARY) {
+ return new StreamCallClientInterceptor(channel.newCall(method, callOptions), method, channel);
+ }
+ return new BlockingCallClientInterceptor(channel.newCall(method, callOptions), method, channel);
}
+
}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/vo/ServiceDescriptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/OperationNameFormatUtil.java
similarity index 57%
rename from apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/vo/ServiceDescriptor.java
rename to apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/OperationNameFormatUtil.java
index 236633361..dc0163b7a 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/vo/ServiceDescriptor.java
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/OperationNameFormatUtil.java
@@ -16,44 +16,26 @@
*
*/
-
-package org.apache.skywalking.apm.plugin.grpc.v1.vo;
+package org.apache.skywalking.apm.plugin.grpc.v1;
import io.grpc.MethodDescriptor;
-/**
- * {@link ServiceDescriptor} indicate the descriptor of an grpc service. it contains {@link #methodType} and
- * {@link #serviceName}.
- *
- * @author zhangxin
- */
-public class ServiceDescriptor {
- private MethodDescriptor.MethodType methodType;
- private String serviceName;
+public class OperationNameFormatUtil {
- public ServiceDescriptor(MethodDescriptor descriptor) {
- this.methodType = descriptor.getType();
- String fullMethodName = descriptor.getFullMethodName();
- this.serviceName = formatServiceName(fullMethodName) + "." + formatMethodName(fullMethodName);
+ public static String formatOperationName(MethodDescriptor methodDescriptor) {
+ String fullMethodName = methodDescriptor.getFullMethodName();
+ return formatServiceName(fullMethodName) + "." + formatMethodName(fullMethodName);
}
- private String formatServiceName(String requestMethodName) {
+ private static String formatServiceName(String requestMethodName) {
int splitIndex = requestMethodName.lastIndexOf("/");
return requestMethodName.substring(0, splitIndex);
}
- private String formatMethodName(String requestMethodName) {
+ private static String formatMethodName(String requestMethodName) {
int splitIndex = requestMethodName.lastIndexOf("/");
String methodName = requestMethodName.substring(splitIndex + 1);
methodName = methodName.substring(0, 1).toLowerCase() + methodName.substring(1);
return methodName;
}
-
- public MethodDescriptor.MethodType getMethodType() {
- return methodType;
- }
-
- public String getServiceName() {
- return serviceName;
- }
}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallHandlerInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallHandlerInterceptor.java
deleted file mode 100644
index c108ab283..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallHandlerInterceptor.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1;
-
-import io.grpc.Metadata;
-import io.grpc.ServerCall;
-import java.lang.reflect.Method;
-import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-
-/**
- * {@link ServerCallHandlerInterceptor} record the {@link Metadata} argument into {@link GRPCDynamicFields} for
- * propagate {@link ContextCarrier} and also record the {@link
- * io.grpc.MethodDescriptor} into {@link GRPCDynamicFields} for building span.
- *
- * @author zhangxin
- */
-public class ServerCallHandlerInterceptor implements InstanceMethodsAroundInterceptor {
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
-
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- GRPCDynamicFields cachedObjects = new GRPCDynamicFields();
- cachedObjects.setMetadata((Metadata)allArguments[1]);
- cachedObjects.setDescriptor(((ServerCall)allArguments[0]).getMethodDescriptor());
- ((EnhancedInstance)ret).setSkyWalkingDynamicField(cachedObjects);
- return ret;
- }
-
- @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
-
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnCloseInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnCloseInterceptor.java
deleted file mode 100644
index 895f6cb6c..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnCloseInterceptor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1;
-
-import java.lang.reflect.Method;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-
-import static org.apache.skywalking.apm.plugin.grpc.v1.define.Constants.ON_NEXT_COUNT_TAG_KEY;
-
-/**
- * {@link ServerCallOnCloseInterceptor} stop the active span when the call end.
- *
- * @author zhangxin
- */
-public class ServerCallOnCloseInterceptor implements InstanceMethodsAroundInterceptor {
-
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
-
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- AbstractSpan abstractSpan = ContextManager.activeSpan();
- abstractSpan.tag(ON_NEXT_COUNT_TAG_KEY, String.valueOf(((GRPCDynamicFields)objInst.getSkyWalkingDynamicField()).getOnNextCount()));
- ContextManager.stopSpan();
- return ret;
- }
-
- @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnMessageInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnMessageInterceptor.java
deleted file mode 100644
index af1acd5e6..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/ServerCallOnMessageInterceptor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1;
-
-import java.lang.reflect.Method;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-
-import static org.apache.skywalking.apm.plugin.grpc.v1.define.Constants.STREAM_OPERATION_NAME_SUFFIX;
-
-/**
- * {@link ServerCallOnMessageInterceptor} create a local span when the server stream receive a message that send by the
- * client.
- *
- * @author zhangxin
- */
-public class ServerCallOnMessageInterceptor implements InstanceMethodsAroundInterceptor {
-
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)objInst.getSkyWalkingDynamicField();
- ContextManager.createLocalSpan(cachedObjects.getRequestMethodName() + STREAM_OPERATION_NAME_SUFFIX);
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- ContextManager.stopSpan();
-
- // record the call count of onNext method
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)objInst.getSkyWalkingDynamicField();
- cachedObjects.incrementOnNextCount();
-
- return ret;
- }
-
- @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/StreamCallClientInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/StreamCallClientInterceptor.java
new file mode 100644
index 000000000..eaca5010c
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/StreamCallClientInterceptor.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.grpc.v1;
+
+import io.grpc.Channel;
+import io.grpc.ClientCall;
+import io.grpc.ForwardingClientCallListener;
+import io.grpc.Metadata;
+import io.grpc.MethodDescriptor;
+import io.grpc.Status;
+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;
+import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.STREAM_ON_NEXT_OPERATION_NAME;
+import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.STREAM_ON_READY_OPERATION_NAME;
+
+public class StreamCallClientInterceptor extends AbstractCallClientInterceptor {
+
+ protected StreamCallClientInterceptor(ClientCall delegate, MethodDescriptor method, Channel channel) {
+ super(delegate, method, channel);
+ }
+
+ @Override
+ public void start(Listener responseListener, Metadata headers) {
+ final ContextCarrier contextCarrier = new ContextCarrier();
+ final AbstractSpan span = ContextManager.createExitSpan(serviceName, contextCarrier, remotePeer);
+ span.setComponent(ComponentsDefine.GRPC);
+ SpanLayer.asRPCFramework(span);
+ CarrierItem contextItem = contextCarrier.items();
+ while (contextItem.hasNext()) {
+ contextItem = contextItem.next();
+ Metadata.Key headerKey = Metadata.Key.of(contextItem.getHeadKey(), Metadata.ASCII_STRING_MARSHALLER);
+ headers.put(headerKey, contextItem.getHeadValue());
+ }
+ delegate().start(new CallListener(responseListener, ContextManager.capture()), headers);
+ ContextManager.stopSpan();
+ }
+
+ private class CallListener extends ForwardingClientCallListener.SimpleForwardingClientCallListener {
+
+ private final ContextSnapshot contextSnapshot;
+
+ protected CallListener(Listener delegate, ContextSnapshot contextSnapshot) {
+ super(delegate);
+ this.contextSnapshot = contextSnapshot;
+ }
+
+ @Override public void onReady() {
+ final AbstractSpan span = ContextManager.createLocalSpan(STREAM_ON_READY_OPERATION_NAME);
+ span.setComponent(ComponentsDefine.GRPC);
+ SpanLayer.asRPCFramework(span);
+ ContextManager.continued(contextSnapshot);
+ delegate().onReady();
+ }
+
+ @Override public void onHeaders(Metadata headers) {
+ delegate().onHeaders(headers);
+ }
+
+ @Override public void onMessage(Object message) {
+ try {
+ ContextManager.createLocalSpan(STREAM_ON_NEXT_OPERATION_NAME);
+ delegate().onMessage(message);
+ } catch (Throwable t) {
+ ContextManager.activeSpan().errorOccurred().log(t);
+ } finally {
+ ContextManager.stopSpan();
+ }
+ }
+
+ @Override public void onClose(Status status, Metadata trailers) {
+ delegate().onClose(status, trailers);
+ if (!status.isOk()) {
+ AbstractSpan activeSpan = ContextManager.activeSpan();
+ activeSpan.errorOccurred().log(status.getCause());
+ Tags.STATUS_CODE.set(activeSpan, status.getCode().name());
+ }
+
+ ContextManager.stopSpan();
+ }
+ }
+
+}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/StreamClientOnCloseInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/StreamClientOnCloseInterceptor.java
deleted file mode 100644
index 1cf45ebb5..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/StreamClientOnCloseInterceptor.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1;
-
-import io.grpc.Metadata;
-import io.grpc.Status;
-import java.lang.reflect.Method;
-import org.apache.skywalking.apm.agent.core.context.tag.Tags;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.apache.skywalking.apm.plugin.grpc.v1.define.Constants;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-
-/**
- * {@link StreamClientOnCloseInterceptor} stop the active span when the call end.
- *
- * @author zhangxin
- */
-public class StreamClientOnCloseInterceptor implements InstanceMethodsAroundInterceptor {
-
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- Status status = (Status)allArguments[0];
- if (status.getCode() == Status.Code.UNAVAILABLE) {
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)objInst.getSkyWalkingDynamicField();
- AbstractSpan span = ContextManager.createLocalSpan(cachedObjects.getRequestMethodName() + Constants.STREAM_CALL_OPERATION_NAME_SUFFIX);
- span.setComponent(ComponentsDefine.GRPC);
- span.setLayer(SpanLayer.RPC_FRAMEWORK);
- ContextManager.continued(cachedObjects.getSnapshot());
- }
-
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- AbstractSpan activeSpan = ContextManager.activeSpan();
- activeSpan.tag(Constants.ON_NEXT_COUNT_TAG_KEY, String.valueOf(((GRPCDynamicFields)objInst.getSkyWalkingDynamicField()).getOnNextCount()));
-
- Status status = (Status)allArguments[0];
- if (status != Status.OK) {
- activeSpan.errorOccurred().log(status.asRuntimeException((Metadata)allArguments[1]));
- Tags.STATUS_CODE.set(activeSpan, status.getCode().toString());
- }
-
- ContextManager.stopSpan();
- return ret;
- }
-
- @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/StreamClientOnReadyInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/StreamClientOnReadyInterceptor.java
deleted file mode 100644
index e28569990..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/StreamClientOnReadyInterceptor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1;
-
-import java.lang.reflect.Method;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.apache.skywalking.apm.plugin.grpc.v1.define.Constants;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.plugin.grpc.v1.vo.GRPCDynamicFields;
-
-/**
- * {@link ServerCallOnReadyInterceptor} create a local span when the client side is ready for send the message to the
- * server side.
- *
- * @author zhangxin
- */
-public class StreamClientOnReadyInterceptor implements InstanceMethodsAroundInterceptor {
-
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- GRPCDynamicFields cachedObjects = (GRPCDynamicFields)objInst.getSkyWalkingDynamicField();
- AbstractSpan span = ContextManager.createLocalSpan(cachedObjects.getRequestMethodName() + Constants.STREAM_CALL_OPERATION_NAME_SUFFIX);
- span.setComponent(ComponentsDefine.GRPC);
- span.setLayer(SpanLayer.RPC_FRAMEWORK);
-
- ContextManager.continued(cachedObjects.getSnapshot());
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- return ret;
- }
-
- @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/ManagedChannelInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java
similarity index 78%
rename from apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/ManagedChannelInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java
index 273fe2c2d..23a2f4cf4 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/ManagedChannelInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java
@@ -16,29 +16,24 @@
*
*/
-
package org.apache.skywalking.apm.plugin.grpc.v1.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
-/**
- * {@link ManagedChannelInstrumentation} presents that skywalking intercept the newCall method in
- * io.grpc.internal.ManagedChannelImpl class by ManagedChannelInterceptor
- *
- * @author zhangxin
- */
-public class ManagedChannelInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "io.grpc.internal.ManagedChannelImpl";
- private static final String ENHANCE_METHOD = "newCall";
- public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ManagedChannelInterceptor";
+public class AbstractServerImplBuilderInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ public static final String ENHANCE_CLASS = "io.grpc.internal.AbstractServerImplBuilder";
+ public static final String ENHANCE_METHOD = "addService";
+ public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.AbstractServerImplBuilderInterceptor";
@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
@@ -48,7 +43,7 @@ public class ManagedChannelInstrumentation extends ClassInstanceMethodsEnhancePl
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override public ElementMatcher getMethodsMatcher() {
- return named(ENHANCE_METHOD);
+ return named(ENHANCE_METHOD).and(takesArgumentWithType(0, "io.grpc.ServerServiceDefinition"));
}
@Override public String getMethodsInterceptor() {
@@ -56,7 +51,7 @@ public class ManagedChannelInstrumentation extends ClassInstanceMethodsEnhancePl
}
@Override public boolean isOverrideArgs() {
- return false;
+ return true;
}
}
};
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/UnaryServerCallHandlerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractStubInstrumentation.java
similarity index 72%
rename from apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/UnaryServerCallHandlerInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractStubInstrumentation.java
index 1f1660cb8..fd3f0739e 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/UnaryServerCallHandlerInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractStubInstrumentation.java
@@ -16,32 +16,38 @@
*
*/
-
package org.apache.skywalking.apm.plugin.grpc.v1.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
-/**
- * {@link UnaryServerCallHandlerInstrumentation} indicates that skywalking enhance the startCall in
- * io.grpc.stub.ServerCalls$StreamingServerCallHandler class by ServerCallHandlerInterceptor.
- *
- * @author zhangxin
- */
-public class UnaryServerCallHandlerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "io.grpc.stub.ServerCalls$StreamingServerCallHandler";
- private static final String ENHANCE_METHOD = "startCall";
- public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ServerCallHandlerInterceptor";
+public class AbstractStubInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[0];
+ public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.AbstractStubInterceptor";
+ public static final String ENHANCE_METHOD = "getChannel";
+ public static final String ENHANCE_CLASS = "io.grpc.stub.AbstractStub";
+
+ @Override
+ protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[] {
+ new ConstructorInterceptPoint() {
+ @Override public ElementMatcher getConstructorMatcher() {
+ return takesArguments(2);
+ }
+
+ @Override public String getConstructorInterceptor() {
+ return INTERCEPT_CLASS;
+ }
+ }
+ };
}
@Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/ClientCallInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/ClientCallInstrumentation.java
deleted file mode 100644
index e05bcbfb7..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/ClientCallInstrumentation.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1.define;
-
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
-import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
-
-import static net.bytebuddy.matcher.ElementMatchers.any;
-import static net.bytebuddy.matcher.ElementMatchers.named;
-
-/**
- * {@link ClientCallInstrumentation} presents that skywalking intercept the start method in
- * io.grpc.internal.ClientCallImpl class by ClientCallsMethodInterceptor
- * and the constructor in io.grpc.internal.ClientCallImpl by ClientCallIConstructorInterceptor
- *
- * @author zhangxin
- */
-public class ClientCallInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "io.grpc.internal.ClientCallImpl";
- private static final String ENHANCE_METHOD = "start";
- public static final String CONSTRUCTOR_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ClientCallIConstructorInterceptor";
- public static final String START_METHOD_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ClientCallStartInterceptor";
-
- @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[] {
- new ConstructorInterceptPoint() {
- @Override public ElementMatcher getConstructorMatcher() {
- return any();
- }
-
- @Override public String getConstructorInterceptor() {
- return CONSTRUCTOR_CLASS;
- }
- }
- };
- }
-
- @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[] {
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ENHANCE_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return START_METHOD_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return true;
- }
- }
- };
- }
-
- @Override protected ClassMatch enhanceClass() {
- return NameMatch.byName(ENHANCE_CLASS);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/ClientCallsInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/ClientCallsInstrumentation.java
deleted file mode 100644
index 9cc07033e..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/ClientCallsInstrumentation.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1.define;
-
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
-import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint;
-
-import static net.bytebuddy.matcher.ElementMatchers.named;
-import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
-
-public class ClientCallsInstrumentation extends ClassStaticMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "io.grpc.stub.ClientCalls";
-
- @Override protected StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() {
- return new StaticMethodsInterceptPoint[] {
- new StaticMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return (named("asyncUnaryRequestCall").and(takesArgumentWithType(2,"io.grpc.ClientCall$Listener")))
- .or(named("asyncStreamingRequestCall"))
- .or(named("blockingUnaryCall"))
- .or(named("futureUnaryCall"));
- }
-
- @Override public String getMethodsInterceptor() {
- return "org.apache.skywalking.apm.plugin.grpc.v1.ClientCallsMethodInterceptor";
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- }
- };
- }
-
- @Override protected ClassMatch enhanceClass() {
- return NameMatch.byName(ENHANCE_CLASS);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/StreamObserverToCallListenerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/StreamObserverToCallListenerInstrumentation.java
deleted file mode 100644
index 63a143783..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/StreamObserverToCallListenerInstrumentation.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1.define;
-
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
-
-import static net.bytebuddy.matcher.ElementMatchers.named;
-import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
-
-/**
- * {@link StreamingServerCallHandlerInstrumentation} presents that skywalking intercept the onReady method
- * by ServerCallOnReadyInterceptor, the onHalfClose method
- * by ServerCallOnCloseInterceptor and the onMessage method
- * by ServerCallOnMessageInterceptor in
- * io.grpc.stub.ServerCalls$StreamingServerCallHandler$StreamingServerCallListener class
- *
- * @author zhangxin
- */
-public class StreamObserverToCallListenerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter";
- public static final String ON_READY_METHOD = "onReady";
- public static final String ON_READY_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.StreamClientOnReadyInterceptor";
- public static final String ON_CLASS_METHOD = "onClose";
- public static final String ON_CLOSE_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.StreamClientOnCloseInterceptor";
- public static final String ON_MESSAGE_METHOD = "onMessage";
- public static final String ON_MESSAGE_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ClientCallOnNextInterceptor";
-
- @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[0];
- }
-
- @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[] {
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_READY_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_READY_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_CLASS_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_CLOSE_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_MESSAGE_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_MESSAGE_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- }
- };
- }
-
- @Override protected ClassMatch enhanceClass() {
- return byName(ENHANCE_CLASS);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/StreamingServerCallHandlerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/StreamingServerCallHandlerInstrumentation.java
deleted file mode 100644
index ee459a496..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/StreamingServerCallHandlerInstrumentation.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1.define;
-
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
-import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
-
-import static net.bytebuddy.matcher.ElementMatchers.named;
-
-/**
- * {@link StreamingServerCallHandlerInstrumentation} presents that skywalking intercept the startCall
- * method in io.grpc.stub.ServerCalls$UnaryServerCallHandler class by
- * ServerCallHandlerInterceptor
- *
- * @author zhangxin
- */
-public class StreamingServerCallHandlerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "io.grpc.stub.ServerCalls$UnaryServerCallHandler";
- private static final String ENHANCE_METHOD = "startCall";
- public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ServerCallHandlerInterceptor";
-
- @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[0];
- }
-
- @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[] {
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ENHANCE_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- }
- };
- }
-
- @Override protected ClassMatch enhanceClass() {
- return NameMatch.byName(ENHANCE_CLASS);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/StreamingServerCallListenerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/StreamingServerCallListenerInstrumentation.java
deleted file mode 100644
index c450f5cd6..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/StreamingServerCallListenerInstrumentation.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1.define;
-
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
-
-import static net.bytebuddy.matcher.ElementMatchers.named;
-import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
-
-/**
- * {@link StreamingServerCallHandlerInstrumentation} presents that skywalking intercept the onReady method
- * by ServerCallOnReadyInterceptor, the onHalfClose method
- * by ServerCallOnCloseInterceptor, the onMessage method by
- * ServerCallOnMessageInterceptor and the onCancel method by
- * ServerCallOnCancelInterceptor in
- * io.grpc.stub.ServerCalls$StreamingServerCallHandler$StreamingServerCallListener class
- *
- * @author zhangxin
- */
-public class StreamingServerCallListenerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "io.grpc.stub.ServerCalls$StreamingServerCallHandler$StreamingServerCallListener";
- public static final String ON_READY_METHOD = "onReady";
- public static final String ON_READ_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ServerCallOnReadyInterceptor";
- public static final String ON_HALF_CLOSE_METHOD = "onHalfClose";
- public static final String ON_HALF_CLOSE_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ServerCallOnCloseInterceptor";
- public static final String ON_MESSAGE_METHOD = "onMessage";
- public static final String ON_MESSAGE_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ServerCallOnMessageInterceptor";
- public static final String ON_CANCEL_METHOD = "onCancel";
- public static final String ON_CANCEL_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ServerCallOnCancelInterceptor";
-
- @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[0];
- }
-
- @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[] {
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_READY_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_READ_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_HALF_CLOSE_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_HALF_CLOSE_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_MESSAGE_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_MESSAGE_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_CANCEL_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_CANCEL_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- }
- };
- }
-
- @Override protected ClassMatch enhanceClass() {
- return byName(ENHANCE_CLASS);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/UnaryClientCallListenerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/UnaryClientCallListenerInstrumentation.java
deleted file mode 100644
index b94f8d952..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/UnaryClientCallListenerInstrumentation.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1.define;
-
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
-
-import static net.bytebuddy.matcher.ElementMatchers.any;
-
-/**
- * {@link UnaryClientCallListenerInstrumentation} indicates that skywalking enhance the onClose method in
- * io.grpc.stub.ClientCalls$UnaryStreamToFuture class by UnaryStreamToFutureConstructorInterceptor
- *
- * @author zhangxin
- */
-public class UnaryClientCallListenerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "io.grpc.stub.ClientCalls$UnaryStreamToFuture";
- public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.UnaryStreamToFutureConstructorInterceptor";
-
- @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[] {
- new ConstructorInterceptPoint() {
- @Override public ElementMatcher getConstructorMatcher() {
- return any();
- }
-
- @Override public String getConstructorInterceptor() {
- return INTERCEPT_CLASS;
- }
- }
- };
- }
-
- @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[0];
- }
-
- @Override protected ClassMatch enhanceClass() {
- return NameMatch.byName(ENHANCE_CLASS);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/UnaryServerCallListenerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/UnaryServerCallListenerInstrumentation.java
deleted file mode 100644
index 0670f965a..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/UnaryServerCallListenerInstrumentation.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1.define;
-
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
-
-import static net.bytebuddy.matcher.ElementMatchers.named;
-import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
-
-/**
- * {@link StreamingServerCallHandlerInstrumentation} presents that skywalking intercept the onReady method
- * by ServerCallOnReadyInterceptor, the onHalfClose method
- * by ServerCallOnCloseInterceptor, the onMessage method by
- * ServerCallOnMessageInterceptor and the onCancel method by
- * ServerCallOnCancelInterceptor in
- * io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener class
- *
- * @author zhangxin
- */
-public class UnaryServerCallListenerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String ENHANCE_CLASS = "io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener";
- public static final String ON_CLOSE_METHOD = "onHalfClose";
- public static final String ON_CLOSE_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ServerCallOnCloseInterceptor";
- public static final String ON_READY_METHOD = "onReady";
- public static final String ON_READY_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ServerCallOnReadyInterceptor";
- public static final String ON_CANCEL_METHOD = "onCancel";
- public static final String ON_CANCEL_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.ServerCallOnCancelInterceptor";
-
- @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[0];
- }
-
- @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[] {
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_CLOSE_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_CLOSE_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_READY_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_READY_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher getMethodsMatcher() {
- return named(ON_CANCEL_METHOD);
- }
-
- @Override public String getMethodsInterceptor() {
- return ON_CANCEL_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- }
- };
- }
-
- @Override protected ClassMatch enhanceClass() {
- return byName(ENHANCE_CLASS);
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/vo/GRPCDynamicFields.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/vo/GRPCDynamicFields.java
deleted file mode 100644
index 32ddd5243..000000000
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/vo/GRPCDynamicFields.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.skywalking.apm.plugin.grpc.v1.vo;
-
-import io.grpc.Metadata;
-import io.grpc.MethodDescriptor;
-import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
-
-/**
- * {@link GRPCDynamicFields} contain the require information of span.
- *
- * @author zhangxin
- */
-public class GRPCDynamicFields {
- private ServiceDescriptor descriptor;
- private Metadata metadata;
- private String authority;
- private ContextSnapshot snapshot;
- private int onNextCount;
-
- public Metadata getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Metadata metadata) {
- this.metadata = metadata;
- }
-
- public String getAuthority() {
- return authority;
- }
-
- public void setAuthority(String authority) {
- this.authority = authority;
- }
-
- public String getRequestMethodName() {
- return descriptor.getServiceName();
- }
-
- public void setDescriptor(MethodDescriptor methodDescriptor) {
- this.descriptor = new ServiceDescriptor(methodDescriptor);
- }
-
- public void setDescriptor(ServiceDescriptor methodDescriptor) {
- this.descriptor = methodDescriptor;
- }
-
- public ServiceDescriptor getDescriptor() {
- return descriptor;
- }
-
- public ContextSnapshot getSnapshot() {
- return snapshot;
- }
-
- public void setSnapshot(ContextSnapshot snapshot) {
- this.snapshot = snapshot;
- }
-
- public MethodDescriptor.MethodType getMethodType() {
- return descriptor.getMethodType();
- }
-
- public void incrementOnNextCount() {
- onNextCount++;
- }
-
- public int getOnNextCount() {
- return onNextCount;
- }
-}
diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/resources/skywalking-plugin.def
index a47047032..b204dce20 100644
--- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/resources/skywalking-plugin.def
+++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/resources/skywalking-plugin.def
@@ -1,9 +1,2 @@
-grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.ClientCallInstrumentation
-grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.UnaryClientCallListenerInstrumentation
-grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.UnaryServerCallListenerInstrumentation
-grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.UnaryServerCallHandlerInstrumentation
-grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.ClientCallsInstrumentation
-grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.ManagedChannelInstrumentation
-grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.StreamingServerCallHandlerInstrumentation
-grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.StreamingServerCallListenerInstrumentation
-grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.StreamObserverToCallListenerInstrumentation
+grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.AbstractStubInstrumentation
+grpc-1.x=org.apache.skywalking.apm.plugin.grpc.v1.define.AbstractServerImplBuilderInstrumentation
\ No newline at end of file