Add shouldStart() call to gRPC instrumentation
MODIFY
instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java
instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java
@@ -45,6 +45,10 @@ final class TracingClientInterceptor implements ClientInterceptor {
MethodDescriptor<REQUEST, RESPONSE> method, CallOptions callOptions, Channel next) {
GrpcRequest request = new GrpcRequest(method, null, null);
Context parentContext = Context.current();
+ if (!instrumenter.shouldStart(parentContext, request)) {
+ return next.newCall(method, callOptions);
+ }
+
Context context = instrumenter.start(parentContext, request);
ClientCall<REQUEST, RESPONSE> result;
try (Scope ignored = context.makeCurrent()) {

MODIFY
instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java
instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java
@@ -46,7 +46,12 @@ final class TracingServerInterceptor implements ServerInterceptor {
call.getMethodDescriptor(),
headers,
call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR));
- Context context = instrumenter.start(Context.current(), request);
+ Context parentContext = Context.current();
+ if (!instrumenter.shouldStart(parentContext, request)) {
+ return next.startCall(call, headers);
+ }
+
+ Context context = instrumenter.start(parentContext, request);
try (Scope ignored = context.makeCurrent()) {
return new TracingServerCall<>(call, context, request).start(headers, next);

Add shouldStart() call to gRPC instrumentation (#6356)