Skip to content

Commit

Permalink
fix context for TracedBatchingContextCallable
Browse files Browse the repository at this point in the history
  • Loading branch information
mutianf committed Jun 23, 2021
1 parent c0f679f commit c307ef8
Showing 1 changed file with 6 additions and 8 deletions.
Expand Up @@ -31,6 +31,7 @@
import com.google.api.gax.retrying.RetryAlgorithm;
import com.google.api.gax.retrying.RetryingExecutorWithContext;
import com.google.api.gax.retrying.ScheduledRetryingExecutor;
import com.google.api.gax.rpc.ApiCallContext;
import com.google.api.gax.rpc.Callables;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsExtractor;
Expand Down Expand Up @@ -512,9 +513,8 @@ private UnaryCallable<BulkMutation, Void> createBulkMutateRowsCallable() {
new HeaderTracerUnaryCallable<>(
userFacing, settings.getHeaderTracer(), spanName.toString());

// TracedBatchingContextCallable needs the last in the callable chain so Batcher can call
// TracedBatchingCOntextCallable#futureCall(request, batchingCallContext) to add batching
// metrics to ApiTracer.
// TracedBatchingContextCallable needs to be the last in the callable chain so Batcher can pass
// batchingCallContext to add batching metrics to ApiTracer.
UnaryCallable<BulkMutation, Void> batchingContextCallable =
new TracedBatchingContextCallable<>(
withHeaderTracer,
Expand Down Expand Up @@ -578,15 +578,13 @@ public Batcher<ByteString, Row> newBulkReadRowsBatcher(
@Nonnull Query query, @Nullable GrpcCallContext ctx) {
Preconditions.checkNotNull(query, "query cannot be null");
UnaryCallable<Query, List<Row>> callable = readRowsCallable().all();
ApiCallContext callContext = clientContext.getDefaultCallContext();
if (ctx != null) {
callable = callable.withDefaultCallContext(ctx);
callContext = ctx.merge(callContext);
}
UnaryCallable<Query, List<Row>> batchingContextCallable =
new TracedBatchingContextCallable(
callable,
clientContext.getDefaultCallContext(),
clientContext.getTracerFactory(),
getSpanName("ReadRows"));
callable, callContext, clientContext.getTracerFactory(), getSpanName("ReadRows"));
return new BatcherImpl<>(
settings.bulkReadRowsSettings().getBatchingDescriptor(),
batchingContextCallable,
Expand Down

0 comments on commit c307ef8

Please sign in to comment.