[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371777178 ## File path: test/plugin/scenarios/grpc-scenario/config/expectedData.yaml ## @@ -15,239 +15,524 @@ # limitations under the License. registryItems: applications: -- {grpc-scenario: 2} + - { grpc-scenario: 2 } instances: -- {grpc-scenario: 1} + - { grpc-scenario: 1 } operationNames: -- grpc-scenario: [Greeter.sayHello, GreeterBlocking.sayHello, - /grpc-scenario/case/grpc-scenario] + - grpc-scenario: [Greeter.sayHello, GreeterBlocking.sayHello, GreeterBlockingError.sayHello, /grpc-scenario/case/grpc-scenario] heartbeat: [] segmentItems: - - applicationCode: grpc-scenario -segmentSize: gt 10 -segments: - - segmentId: not null -spans: - - operationName: GreeterBlocking.sayHello -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: RPCFramework -startTime: nq 0 -endTime: nq 0 -componentId: 23 -componentName: '' -isError: false -spanType: Entry -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: /grpc-scenario/case/grpc-scenario, networkAddressId: 0, - entryEndpointId: 0, refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '127.0.0.1:18080', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: Greeter.sayHello -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: RPCFramework -startTime: nq 0 -endTime: nq 0 -componentId: 23 -componentName: '' -isError: false -spanType: Entry -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: /grpc-scenario/case/grpc-scenario, networkAddressId: 0, - entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '127.0.0.1:18080', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: GreeterBlocking.sayHello/server/RequestObserver/onNext -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: Unknown -startTime: nq 0 -endTime: nq 0 -componentId: 0 -componentName: '' -isError: false -spanType: Local -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: GreeterBlocking.sayHello, networkAddressId: 0, - entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: Greeter.sayHello/server/RequestObserver/onNext -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: Unknown -startTime: nq 0 -endTime: nq 0 -componentId: 0 -componentName: '' -isError: false -spanType: Local -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: Greeter.sayHello, networkAddressId: 0, - entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: Greeter.sayHello/client/ResponseObserver/onNext -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: Unknown -startTime: nq 0 -endTime: nq 0 -componentId: 0 -componentName: '' -isError: false -spanType: Local -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: /grpc-scenario/case/grpc-scenario, networkAddressId: 0, - entryEndpointId: 0, refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '',
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371669444 ## File path: test/plugin/scenarios/grpc-scenario/config/expectedData.yaml ## @@ -15,239 +15,524 @@ # limitations under the License. registryItems: applications: -- {grpc-scenario: 2} + - { grpc-scenario: 2 } instances: -- {grpc-scenario: 1} + - { grpc-scenario: 1 } operationNames: -- grpc-scenario: [Greeter.sayHello, GreeterBlocking.sayHello, - /grpc-scenario/case/grpc-scenario] + - grpc-scenario: [Greeter.sayHello, GreeterBlocking.sayHello, GreeterBlockingError.sayHello, /grpc-scenario/case/grpc-scenario] heartbeat: [] segmentItems: - - applicationCode: grpc-scenario -segmentSize: gt 10 -segments: - - segmentId: not null -spans: - - operationName: GreeterBlocking.sayHello -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: RPCFramework -startTime: nq 0 -endTime: nq 0 -componentId: 23 -componentName: '' -isError: false -spanType: Entry -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: /grpc-scenario/case/grpc-scenario, networkAddressId: 0, - entryEndpointId: 0, refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '127.0.0.1:18080', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: Greeter.sayHello -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: RPCFramework -startTime: nq 0 -endTime: nq 0 -componentId: 23 -componentName: '' -isError: false -spanType: Entry -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: /grpc-scenario/case/grpc-scenario, networkAddressId: 0, - entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '127.0.0.1:18080', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: GreeterBlocking.sayHello/server/RequestObserver/onNext -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: Unknown -startTime: nq 0 -endTime: nq 0 -componentId: 0 -componentName: '' -isError: false -spanType: Local -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: GreeterBlocking.sayHello, networkAddressId: 0, - entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: Greeter.sayHello/server/RequestObserver/onNext -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: Unknown -startTime: nq 0 -endTime: nq 0 -componentId: 0 -componentName: '' -isError: false -spanType: Local -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: Greeter.sayHello, networkAddressId: 0, - entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: Greeter.sayHello/client/ResponseObserver/onNext -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: Unknown -startTime: nq 0 -endTime: nq 0 -componentId: 0 -componentName: '' -isError: false -spanType: Local -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: /grpc-scenario/case/grpc-scenario, networkAddressId: 0, - entryEndpointId: 0, refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '',
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371648214 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/TracingServerCall.java ## @@ -0,0 +1,111 @@ +/* + * 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.server; + +import io.grpc.ForwardingServerCall; +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.Status; +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 org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.*; + +/** + * @author wang zheng, kanro + */ +public class TracingServerCall extends ForwardingServerCall.SimpleForwardingServerCall { + +private final String operationPrefix; +private final ContextSnapshot contextSnapshot; + +protected TracingServerCall(ServerCall delegate, ContextSnapshot contextSnapshot) { +super(delegate); +this.operationPrefix = OperationNameFormatUtil.formatOperationName(delegate.getMethodDescriptor()) + SERVER; +this.contextSnapshot = contextSnapshot; +} + +@Override +public void sendMessage(RESPONSE message) { +// We just create the request on message span for server stream calls. +if (!getMethodDescriptor().getType().serverSendsOneMessage()) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + RESPONSE_ON_MESSAGE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +} catch (Throwable t) { +ContextManager.activeSpan().errorOccurred().log(t); +throw t; +} finally { +super.sendMessage(message); +ContextManager.stopSpan(); +} +} else { +super.sendMessage(message); +} +} + +@Override +public void close(Status status, Metadata trailers) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + RESPONSE_ON_CLOSE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); + +switch (status.getCode()) { +case OK: +break; +// UNKNOWN/INTERNAL status code will case error in this span. +// Those status code means some unexpected error occurred in server. +// Similar to 5XX in HTTP status. +case UNKNOWN: +case INTERNAL: +if (status.getCause() == null) { +span.errorOccurred().log(status.asRuntimeException()); +} else { +span.errorOccurred().log(status.getCause()); +} +break; +// Other status code means some predictable error occurred in server. +// Like PERMISSION_DENIED or UNAUTHENTICATED somethings. +// Similar to 4XX in HTTP status. +default: +// But if the status still has cause exception, we will log it too. +if (status.getCause() != null) { +span.errorOccurred().log(status.getCause()); +} +break; +} +Tags.STATUS_CODE.set(span, status.getCode().name()); +} catch (Throwable t) { Review comment: Please
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371647780 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/TracingServerCallListener.java ## @@ -0,0 +1,102 @@ +/* + * 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.server; + +import io.grpc.ForwardingServerCallListener; +import io.grpc.MethodDescriptor; +import io.grpc.ServerCall; +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.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.*; + +/** + * @author wang zheng, kanro + */ +public class TracingServerCallListener extends ForwardingServerCallListener.SimpleForwardingServerCallListener { + +private final ContextSnapshot contextSnapshot; +private final MethodDescriptor.MethodType methodType; +private final String operationPrefix; + +protected TracingServerCallListener(ServerCall.Listener delegate, MethodDescriptor descriptor, +ContextSnapshot contextSnapshot) { +super(delegate); +this.contextSnapshot = contextSnapshot; +this.methodType = descriptor.getType(); +this.operationPrefix = OperationNameFormatUtil.formatOperationName(descriptor) + SERVER; +} + +@Override +public void onMessage(REQUEST message) { +// We just create the request on message span for client stream calls. +if (!methodType.clientSendsOneMessage()) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + REQUEST_ON_MESSAGE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +} catch (Throwable t) { +ContextManager.activeSpan().errorOccurred().log(t); Review comment: As I last comment, please just `try/final`, but not `catch`. I just want to guarantee our plugins would not break the original codes even our plugins have bugs. Please recheck the codes based on this rule. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371645672 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/TracingServerCall.java ## @@ -0,0 +1,111 @@ +/* + * 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.server; + +import io.grpc.ForwardingServerCall; +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.Status; +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 org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.*; + +/** + * @author wang zheng, kanro + */ +public class TracingServerCall extends ForwardingServerCall.SimpleForwardingServerCall { + +private final String operationPrefix; +private final ContextSnapshot contextSnapshot; + +protected TracingServerCall(ServerCall delegate, ContextSnapshot contextSnapshot) { +super(delegate); +this.operationPrefix = OperationNameFormatUtil.formatOperationName(delegate.getMethodDescriptor()) + SERVER; +this.contextSnapshot = contextSnapshot; +} + +@Override +public void sendMessage(RESPONSE message) { +// We just create the request on message span for server stream calls. +if (!getMethodDescriptor().getType().serverSendsOneMessage()) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + RESPONSE_ON_MESSAGE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +} catch (Throwable t) { +ContextManager.activeSpan().errorOccurred().log(t); +throw t; +} finally { +super.sendMessage(message); +ContextManager.stopSpan(); +} +} else { +super.sendMessage(message); +} +} + +@Override +public void close(Status status, Metadata trailers) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + RESPONSE_ON_CLOSE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); + +switch (status.getCode()) { +case OK: +break; +// UNKNOWN/INTERNAL status code will case error in this span. +// Those status code means some unexpected error occurred in server. +// Similar to 5XX in HTTP status. +case UNKNOWN: +case INTERNAL: +if (status.getCause() == null) { +span.errorOccurred().log(status.asRuntimeException()); +} else { +span.errorOccurred().log(status.getCause()); +} +break; +// Other status code means some predictable error occurred in server. +// Like PERMISSION_DENIED or UNAUTHENTICATED somethings. +// Similar to 4XX in HTTP status. +default: +// But if the status still has cause exception, we will log it too. +if (status.getCause() != null) { +span.errorOccurred().log(status.getCause()); +} +break; +} +Tags.STATUS_CODE.set(span, status.getCode().name()); +} catch (Throwable t) { Review comment: What
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r37758 ## File path: test/plugin/scenarios/grpc-scenario/config/expectedData.yaml ## @@ -15,239 +15,542 @@ # limitations under the License. registryItems: applications: -- {grpc-scenario: 2} + - { grpc-scenario: 2 } instances: -- {grpc-scenario: 1} + - { grpc-scenario: 1 } operationNames: -- grpc-scenario: [Greeter.sayHello, GreeterBlocking.sayHello, - /grpc-scenario/case/grpc-scenario] + - grpc-scenario: [/grpc-scenario/case/healthCheck, Greeter.sayHello, GreeterBlocking.sayHello, GreeterBlockingError.sayHello, /grpc-scenario/case/grpc-scenario] Review comment: Health check should not be included. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r37799 ## File path: test/plugin/scenarios/grpc-scenario/config/expectedData.yaml ## @@ -15,239 +15,542 @@ # limitations under the License. registryItems: applications: -- {grpc-scenario: 2} + - { grpc-scenario: 2 } instances: -- {grpc-scenario: 1} + - { grpc-scenario: 1 } operationNames: -- grpc-scenario: [Greeter.sayHello, GreeterBlocking.sayHello, - /grpc-scenario/case/grpc-scenario] + - grpc-scenario: [/grpc-scenario/case/healthCheck, Greeter.sayHello, GreeterBlocking.sayHello, GreeterBlockingError.sayHello, /grpc-scenario/case/grpc-scenario] heartbeat: [] segmentItems: - - applicationCode: grpc-scenario -segmentSize: gt 10 -segments: - - segmentId: not null -spans: - - operationName: GreeterBlocking.sayHello -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: RPCFramework -startTime: nq 0 -endTime: nq 0 -componentId: 23 -componentName: '' -isError: false -spanType: Entry -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: /grpc-scenario/case/grpc-scenario, networkAddressId: 0, - entryEndpointId: 0, refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '127.0.0.1:18080', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: Greeter.sayHello -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: RPCFramework -startTime: nq 0 -endTime: nq 0 -componentId: 23 -componentName: '' -isError: false -spanType: Entry -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: /grpc-scenario/case/grpc-scenario, networkAddressId: 0, - entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '127.0.0.1:18080', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: GreeterBlocking.sayHello/server/RequestObserver/onNext -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: Unknown -startTime: nq 0 -endTime: nq 0 -componentId: 0 -componentName: '' -isError: false -spanType: Local -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: GreeterBlocking.sayHello, networkAddressId: 0, - entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: Greeter.sayHello/server/RequestObserver/onNext -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: Unknown -startTime: nq 0 -endTime: nq 0 -componentId: 0 -componentName: '' -isError: false -spanType: Local -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: Greeter.sayHello, networkAddressId: 0, - entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, - parentServiceInstanceId: 1, networkAddress: '', entryEndpoint: /grpc-scenario/case/grpc-scenario, - entryServiceInstanceId: 1} - - segmentId: not null -spans: - - operationName: Greeter.sayHello/client/ResponseObserver/onNext -operationId: 0 -parentSpanId: -1 -spanId: 0 -spanLayer: Unknown -startTime: nq 0 -endTime: nq 0 -componentId: 0 -componentName: '' -isError: false -spanType: Local -peer: '' -peerId: 0 -refs: - - {parentEndpointId: 0, parentEndpoint: /grpc-scenario/case/grpc-scenario, networkAddressId: 0, - entryEndpointId: 0, refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, - parentServiceInstanceId:
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371104922 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/TracingServerCallListener.java ## @@ -0,0 +1,102 @@ +/* + * 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.server; + +import io.grpc.ForwardingServerCallListener; +import io.grpc.MethodDescriptor; +import io.grpc.ServerCall; +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.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.*; + +/** + * @author wang zheng, kanro + */ +public class TracingServerCallListener extends ForwardingServerCallListener.SimpleForwardingServerCallListener { + +private final ContextSnapshot contextSnapshot; +private final MethodDescriptor.MethodType methodType; +private final String operationPrefix; + +protected TracingServerCallListener(ServerCall.Listener delegate, MethodDescriptor descriptor, +ContextSnapshot contextSnapshot) { +super(delegate); +this.contextSnapshot = contextSnapshot; +this.methodType = descriptor.getType(); +this.operationPrefix = OperationNameFormatUtil.formatOperationName(descriptor) + SERVER; +} + +@Override +public void onMessage(REQUEST message) { +// We just create the request on message span for client stream calls. +if (!methodType.clientSendsOneMessage()) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + REQUEST_ON_MESSAGE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +super.onMessage(message); Review comment: A similar suggestion, `try/final` should be added here. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371102796 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/TracingServerCall.java ## @@ -0,0 +1,111 @@ +/* + * 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.server; + +import io.grpc.ForwardingServerCall; +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.Status; +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 org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.*; + +/** + * @author wang zheng, kanro + */ +public class TracingServerCall extends ForwardingServerCall.SimpleForwardingServerCall { + +private final String operationPrefix; +private final ContextSnapshot contextSnapshot; + +protected TracingServerCall(ServerCall delegate, ContextSnapshot contextSnapshot) { +super(delegate); +this.operationPrefix = OperationNameFormatUtil.formatOperationName(delegate.getMethodDescriptor()) + SERVER; +this.contextSnapshot = contextSnapshot; +} + +@Override +public void sendMessage(RESPONSE message) { +// We just create the request on message span for server stream calls. +if (!getMethodDescriptor().getType().serverSendsOneMessage()) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + RESPONSE_ON_MESSAGE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +super.sendMessage(message); +} catch (Throwable t) { +ContextManager.activeSpan().errorOccurred().log(t); +throw t; +} finally { +ContextManager.stopSpan(); +} +} else { +super.sendMessage(message); +} +} + +@Override +public void close(Status status, Metadata trailers) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + RESPONSE_ON_CLOSE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); + +switch (status.getCode()) { +case OK: +break; +// UNKNOWN/INTERNAL status code will case error in this span. +// Those status code means some unexpected error occurred in server. +// Similar to 5XX in HTTP status. +case UNKNOWN: +case INTERNAL: +if (status.getCause() == null) { +span.errorOccurred().log(status.asRuntimeException()); +} else { +span.errorOccurred().log(status.getCause()); +} +break; +// Other status code means some predictable error occurred in server. +// Like PERMISSION_DENIED or UNAUTHENTICATED somethings. +// Similar to 4XX in HTTP status. +default: Review comment: `case UNKNOWN`, `case INTERNAL` and `default` seem to have the same logic. What is the difference? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371105013 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/TracingServerCallListener.java ## @@ -0,0 +1,102 @@ +/* + * 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.server; + +import io.grpc.ForwardingServerCallListener; +import io.grpc.MethodDescriptor; +import io.grpc.ServerCall; +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.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.*; + +/** + * @author wang zheng, kanro + */ +public class TracingServerCallListener extends ForwardingServerCallListener.SimpleForwardingServerCallListener { + +private final ContextSnapshot contextSnapshot; +private final MethodDescriptor.MethodType methodType; +private final String operationPrefix; + +protected TracingServerCallListener(ServerCall.Listener delegate, MethodDescriptor descriptor, +ContextSnapshot contextSnapshot) { +super(delegate); +this.contextSnapshot = contextSnapshot; +this.methodType = descriptor.getType(); +this.operationPrefix = OperationNameFormatUtil.formatOperationName(descriptor) + SERVER; +} + +@Override +public void onMessage(REQUEST message) { +// We just create the request on message span for client stream calls. +if (!methodType.clientSendsOneMessage()) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + REQUEST_ON_MESSAGE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +super.onMessage(message); +} catch (Throwable t) { +ContextManager.activeSpan().errorOccurred().log(t); +throw t; +} finally { +ContextManager.stopSpan(); +} +} else { +super.onMessage(message); +} +} + +@Override +public void onCancel() { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + REQUEST_ON_CANCEL_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +super.onCancel(); Review comment: A similar suggestion, `try/final` should be added here. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371105093 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/TracingServerCallListener.java ## @@ -0,0 +1,102 @@ +/* + * 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.server; + +import io.grpc.ForwardingServerCallListener; +import io.grpc.MethodDescriptor; +import io.grpc.ServerCall; +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.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.*; + +/** + * @author wang zheng, kanro + */ +public class TracingServerCallListener extends ForwardingServerCallListener.SimpleForwardingServerCallListener { + +private final ContextSnapshot contextSnapshot; +private final MethodDescriptor.MethodType methodType; +private final String operationPrefix; + +protected TracingServerCallListener(ServerCall.Listener delegate, MethodDescriptor descriptor, +ContextSnapshot contextSnapshot) { +super(delegate); +this.contextSnapshot = contextSnapshot; +this.methodType = descriptor.getType(); +this.operationPrefix = OperationNameFormatUtil.formatOperationName(descriptor) + SERVER; +} + +@Override +public void onMessage(REQUEST message) { +// We just create the request on message span for client stream calls. +if (!methodType.clientSendsOneMessage()) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + REQUEST_ON_MESSAGE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +super.onMessage(message); +} catch (Throwable t) { +ContextManager.activeSpan().errorOccurred().log(t); +throw t; +} finally { +ContextManager.stopSpan(); +} +} else { +super.onMessage(message); +} +} + +@Override +public void onCancel() { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + REQUEST_ON_CANCEL_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +super.onCancel(); +} catch (Throwable t) { +ContextManager.activeSpan().errorOccurred().log(t); +throw t; +} finally { +ContextManager.stopSpan(); +} +} + +@Override +public void onHalfClose() { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + REQUEST_ON_COMPLETE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +super.onHalfClose(); Review comment: A similar suggestion, `try/final` should be added here. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371099766 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/client/TracingClientCall.java ## @@ -0,0 +1,201 @@ +/* + * 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.client; + +import io.grpc.*; +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 org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil; + +import javax.annotation.Nullable; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.*; +import static org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil.formatOperationName; + +/** + * Fully client tracing for external gRPC server which not be registered in the same Skywalking server. Review comment: This comment seems not right. Do you miss the changes of old version? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r371104619 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/TracingServerCall.java ## @@ -0,0 +1,111 @@ +/* + * 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.server; + +import io.grpc.ForwardingServerCall; +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.Status; +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 org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.*; + +/** + * @author wang zheng, kanro + */ +public class TracingServerCall extends ForwardingServerCall.SimpleForwardingServerCall { + +private final String operationPrefix; +private final ContextSnapshot contextSnapshot; + +protected TracingServerCall(ServerCall delegate, ContextSnapshot contextSnapshot) { +super(delegate); +this.operationPrefix = OperationNameFormatUtil.formatOperationName(delegate.getMethodDescriptor()) + SERVER; +this.contextSnapshot = contextSnapshot; +} + +@Override +public void sendMessage(RESPONSE message) { +// We just create the request on message span for server stream calls. +if (!getMethodDescriptor().getType().serverSendsOneMessage()) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + RESPONSE_ON_MESSAGE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); +super.sendMessage(message); +} catch (Throwable t) { +ContextManager.activeSpan().errorOccurred().log(t); +throw t; +} finally { +ContextManager.stopSpan(); +} +} else { +super.sendMessage(message); +} +} + +@Override +public void close(Status status, Metadata trailers) { +try { +final AbstractSpan span = ContextManager.createLocalSpan(operationPrefix + RESPONSE_ON_CLOSE_OPERATION_NAME); +span.setComponent(ComponentsDefine.GRPC); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.continued(contextSnapshot); + +switch (status.getCode()) { +case OK: +break; +// UNKNOWN/INTERNAL status code will case error in this span. +// Those status code means some unexpected error occurred in server. +// Similar to 5XX in HTTP status. +case UNKNOWN: +case INTERNAL: +if (status.getCause() == null) { +span.errorOccurred().log(status.asRuntimeException()); +} else { +span.errorOccurred().log(status.getCause()); +} +break; +// Other status code means some predictable error occurred in server. +// Like PERMISSION_DENIED or UNAUTHENTICATED somethings. +// Similar to 4XX in HTTP status. +default: +// But if the status still has cause exception, we will log it too. +if (status.getCause() != null) { +span.errorOccurred().log(status.getCause()); +} +break; +} +Tags.STATUS_CODE.set(span, status.getCode().name()); +super.close(status, trailers); Review
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r366914052 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/client/BlockingCallInterceptor.java ## @@ -16,43 +16,48 @@ * */ -package org.apache.skywalking.apm.plugin.grpc.v1; +package org.apache.skywalking.apm.plugin.grpc.v1.client; import io.grpc.Channel; import io.grpc.MethodDescriptor; -import java.lang.reflect.Method; 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.context.trace.SpanLayer; 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 java.lang.reflect.Method; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.BLOCKING_CALL_EXIT_SPAN; import static org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil.formatOperationName; /** - * @author zhang xin + * @author zhang xin, kanro */ public class BlockingCallInterceptor implements StaticMethodsAroundInterceptor { -@Override public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, -MethodInterceptResult result) { -Channel channel = (Channel)allArguments[0]; -MethodDescriptor methodDescriptor = (MethodDescriptor)allArguments[1]; +@Override +public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + MethodInterceptResult result) { +Channel channel = (Channel) allArguments[0]; +MethodDescriptor methodDescriptor = (MethodDescriptor) allArguments[1]; final AbstractSpan span = ContextManager.createExitSpan(formatOperationName(methodDescriptor), channel.authority()); span.setComponent(ComponentsDefine.GRPC); -SpanLayer.asRPCFramework(span); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.getRuntimeContext().put(BLOCKING_CALL_EXIT_SPAN, span); Review comment: If not, whether the multiple RPCs will trigger dirty read? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r366911621 ## File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java ## @@ -388,5 +390,26 @@ */ public static int HTTP_PARAMS_LENGTH_THRESHOLD = 1024; } + +public static class Grpc { +/** + * If this config is false, only client spans of peer which configured in {@link Grpc#INCLUDED_CLIENT_TRACING_PEERS} + * will be collected. In this mode {@link Grpc#EXCLUDED_CLIENT_TRACING_PEERS} will override {@link Grpc#INCLUDED_CLIENT_TRACING_PEERS}. + * + * If this config is true, only client spans of peer which configured in {@link Grpc#EXCLUDED_CLIENT_TRACING_PEERS} + * will not be collected. In this mode {@link Grpc#INCLUDED_CLIENT_TRACING_PEERS} will override {@link Grpc#EXCLUDED_CLIENT_TRACING_PEERS}. + */ +public static boolean DEFAULT_CLIENT_TRACING_ENABLE = false; + +/** + * Included client tracing peers. gRPC plugin will collect client spans of configured config. + */ +public static List INCLUDED_CLIENT_TRACING_PEERS = new LinkedList<>(); + +/** + * Excluded client tracing peers. gRPC plugin will not collect client spans of configured config. + */ +public static List EXCLUDED_CLIENT_TRACING_PEERS = new LinkedList<>(); Review comment: Do you forget to remove all these? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin
wu-sheng commented on a change in pull request #4177: Enhance gRPC plugin URL: https://github.com/apache/skywalking/pull/4177#discussion_r366913385 ## File path: apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/client/BlockingCallInterceptor.java ## @@ -16,43 +16,48 @@ * */ -package org.apache.skywalking.apm.plugin.grpc.v1; +package org.apache.skywalking.apm.plugin.grpc.v1.client; import io.grpc.Channel; import io.grpc.MethodDescriptor; -import java.lang.reflect.Method; 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.context.trace.SpanLayer; 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 java.lang.reflect.Method; + +import static org.apache.skywalking.apm.plugin.grpc.v1.Constants.BLOCKING_CALL_EXIT_SPAN; import static org.apache.skywalking.apm.plugin.grpc.v1.OperationNameFormatUtil.formatOperationName; /** - * @author zhang xin + * @author zhang xin, kanro */ public class BlockingCallInterceptor implements StaticMethodsAroundInterceptor { -@Override public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, -MethodInterceptResult result) { -Channel channel = (Channel)allArguments[0]; -MethodDescriptor methodDescriptor = (MethodDescriptor)allArguments[1]; +@Override +public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + MethodInterceptResult result) { +Channel channel = (Channel) allArguments[0]; +MethodDescriptor methodDescriptor = (MethodDescriptor) allArguments[1]; final AbstractSpan span = ContextManager.createExitSpan(formatOperationName(methodDescriptor), channel.authority()); span.setComponent(ComponentsDefine.GRPC); -SpanLayer.asRPCFramework(span); +span.setLayer(SpanLayer.RPC_FRAMEWORK); +ContextManager.getRuntimeContext().put(BLOCKING_CALL_EXIT_SPAN, span); Review comment: When will remove this from the RuntimeContext? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services