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) {
|
MethodDescriptor<REQUEST, RESPONSE> method, CallOptions callOptions, Channel next) {
|
||||||
GrpcRequest request = new GrpcRequest(method, null, null);
|
GrpcRequest request = new GrpcRequest(method, null, null);
|
||||||
Context parentContext = Context.current();
|
Context parentContext = Context.current();
|
||||||
|
if (!instrumenter.shouldStart(parentContext, request)) {
|
||||||
|
return next.newCall(method, callOptions);
|
||||||
|
}
|
||||||
|
|
||||||
Context context = instrumenter.start(parentContext, request);
|
Context context = instrumenter.start(parentContext, request);
|
||||||
ClientCall<REQUEST, RESPONSE> result;
|
ClientCall<REQUEST, RESPONSE> result;
|
||||||
try (Scope ignored = context.makeCurrent()) {
|
try (Scope ignored = context.makeCurrent()) {
|
||||||
|
|
|
@ -46,7 +46,12 @@ final class TracingServerInterceptor implements ServerInterceptor {
|
||||||
call.getMethodDescriptor(),
|
call.getMethodDescriptor(),
|
||||||
headers,
|
headers,
|
||||||
call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR));
|
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()) {
|
try (Scope ignored = context.makeCurrent()) {
|
||||||
return new TracingServerCall<>(call, context, request).start(headers, next);
|
return new TracingServerCall<>(call, context, request).start(headers, next);
|
||||||
|
|
Loading…
Reference in New Issue