Add shouldStart() call to gRPC instrumentation (#6356)
This commit is contained in:
parent
11e46f5694
commit
fcda760ad5
|
@ -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()) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue