Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbernstein2 committed Feb 21, 2019
1 parent 05e13b6 commit 8579ac1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public static EnhancedBigtableStub create(EnhancedBigtableStubSettings settings)
.setStreamWatchdogProvider(settings.getStreamWatchdogProvider())
.setStreamWatchdogCheckInterval(settings.getStreamWatchdogCheckInterval())
// Force the base stub to use a different TracerFactory
.setTracerFactory(new WrappedTracerFactory(settings.getTracerFactory(), TRACING_INNER_CLIENT_NAME));
.setTracerFactory(
new WrappedTracerFactory(settings.getTracerFactory(), TRACING_INNER_CLIENT_NAME));

// ReadRow retries are handled in the overlay: disable retries in the base layer (but make
// sure to preserve the exception callable settings).
Expand Down Expand Up @@ -150,9 +151,7 @@ public static EnhancedBigtableStub create(EnhancedBigtableStubSettings settings)
GrpcBigtableStub stub = new GrpcBigtableStub(baseSettings, clientContext);

// Make sure to keep the original tracer factory for the outer client.
clientContext = clientContext.toBuilder()
.setTracerFactory(settings.getTracerFactory())
.build();
clientContext = clientContext.toBuilder().setTracerFactory(settings.getTracerFactory()).build();

return new EnhancedBigtableStub(settings, clientContext, stub);
}
Expand Down Expand Up @@ -263,9 +262,11 @@ private <RowT> ServerStreamingCallable<Query, RowT> createReadRowsCallable(

ReadRowsUserCallable<RowT> userFacing = new ReadRowsUserCallable<>(filtering, requestContext);

TracedServerStreamingCallable<Query, RowT> traced = new TracedServerStreamingCallable<>(
userFacing, clientContext.getTracerFactory(), SpanName.of(TRACING_OUTER_CLIENT_NAME, "ReadRows")
);
TracedServerStreamingCallable<Query, RowT> traced =
new TracedServerStreamingCallable<>(
userFacing,
clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "ReadRows"));

return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Expand All @@ -291,11 +292,11 @@ private UnaryCallable<String, List<KeyOffset>> createSampleRowKeysCallable() {
UnaryCallable<String, List<KeyOffset>> userFacing =
new SampleRowKeysCallable(retryable, requestContext);

UnaryCallable<String, List<KeyOffset>> traced = new TracedUnaryCallable<>(
userFacing,
clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "SampleRowKeys")
);
UnaryCallable<String, List<KeyOffset>> traced =
new TracedUnaryCallable<>(
userFacing,
clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "SampleRowKeys"));

return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Expand All @@ -310,11 +311,11 @@ private UnaryCallable<String, List<KeyOffset>> createSampleRowKeysCallable() {
private UnaryCallable<RowMutation, Void> createMutateRowCallable() {
MutateRowCallable userFacing = new MutateRowCallable(stub.mutateRowCallable(), requestContext);

UnaryCallable<RowMutation, Void> traced = new TracedUnaryCallable<>(
userFacing,
clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "MutateRow")
);
UnaryCallable<RowMutation, Void> traced =
new TracedUnaryCallable<>(
userFacing,
clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "MutateRow"));

return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Expand All @@ -335,11 +336,14 @@ private UnaryCallable<RowMutation, Void> createMutateRowCallable() {
*/
private UnaryCallable<BulkMutation, Void> createBulkMutateRowsCallable() {
UnaryCallable<MutateRowsRequest, Void> baseCallable = createMutateRowsBaseCallable();
BulkMutateRowsUserFacingCallable userFacing = new BulkMutateRowsUserFacingCallable(
baseCallable, requestContext);
BulkMutateRowsUserFacingCallable userFacing =
new BulkMutateRowsUserFacingCallable(baseCallable, requestContext);

TracedUnaryCallable<BulkMutation, Void> traced = new TracedUnaryCallable<>(
userFacing, clientContext.getTracerFactory(), SpanName.of(TRACING_OUTER_CLIENT_NAME, "BulkMutateRows"));
TracedUnaryCallable<BulkMutation, Void> traced =
new TracedUnaryCallable<>(
userFacing,
clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "BulkMutateRows"));

return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Expand Down Expand Up @@ -368,9 +372,12 @@ private UnaryCallable<RowMutation, Void> createBulkMutateRowsBatchingCallable()
BatchingCallSettings.newBuilder(new MutateRowsBatchingDescriptor())
.setBatchingSettings(settings.bulkMutateRowsSettings().getBatchingSettings());

TracedBatchingCallable<MutateRowsRequest, Void> traced = new TracedBatchingCallable<>(
baseCallable, clientContext.getTracerFactory(), SpanName.of(TRACING_OUTER_CLIENT_NAME, "BulkMutateRows"),
batchingCallSettings.getBatchingDescriptor());
TracedBatchingCallable<MutateRowsRequest, Void> traced =
new TracedBatchingCallable<>(
baseCallable,
clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "BulkMutateRows"),
batchingCallSettings.getBatchingDescriptor());

UnaryCallable<MutateRowsRequest, Void> batching =
Callables.batching(traced, batchingCallSettings.build(), clientContext);
Expand Down Expand Up @@ -415,8 +422,11 @@ private UnaryCallable<ConditionalRowMutation, Boolean> createCheckAndMutateRowCa
CheckAndMutateRowCallable userFacing =
new CheckAndMutateRowCallable(stub.checkAndMutateRowCallable(), requestContext);

TracedUnaryCallable<ConditionalRowMutation, Boolean> traced = new TracedUnaryCallable<>(
userFacing, clientContext.getTracerFactory(), SpanName.of(TRACING_OUTER_CLIENT_NAME, "CheckAndMutateRow"));
TracedUnaryCallable<ConditionalRowMutation, Boolean> traced =
new TracedUnaryCallable<>(
userFacing,
clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "CheckAndMutateRow"));

return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Expand All @@ -434,9 +444,11 @@ private UnaryCallable<ReadModifyWriteRow, Row> createReadModifyWriteRowCallable(
ReadModifyWriteRowCallable userFacing =
new ReadModifyWriteRowCallable(stub.readModifyWriteRowCallable(), requestContext);

TracedUnaryCallable<ReadModifyWriteRow, Row> traced = new TracedUnaryCallable<>(
userFacing, clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "ReadModifyWriteRow"));
TracedUnaryCallable<ReadModifyWriteRow, Row> traced =
new TracedUnaryCallable<>(
userFacing,
clientContext.getTracerFactory(),
SpanName.of(TRACING_OUTER_CLIENT_NAME, "ReadModifyWriteRow"));

return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.graph.ImmutableNetwork;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import org.threeten.bp.Duration;
Expand Down Expand Up @@ -276,13 +273,12 @@ private Builder() {
setStreamWatchdogCheckInterval(baseDefaults.getStreamWatchdogCheckInterval());
setStreamWatchdogProvider(baseDefaults.getStreamWatchdogProvider());

setTracerFactory(new OpencensusTracerFactory(
ImmutableMap.of(
"gax", GaxGrpcProperties.getGaxGrpcVersion(),
"grpc", GaxGrpcProperties.getGrpcVersion(),
"gapic", GaxProperties.getLibraryVersion(EnhancedBigtableStubSettings.class)
)
));
setTracerFactory(
new OpencensusTracerFactory(
ImmutableMap.of(
"gax", GaxGrpcProperties.getGaxGrpcVersion(),
"grpc", GaxGrpcProperties.getGrpcVersion(),
"gapic", GaxProperties.getLibraryVersion(EnhancedBigtableStubSettings.class))));

// Per-method settings using baseSettings for defaults.
readRowsSettings = ServerStreamingCallSettings.newBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import com.google.api.core.InternalApi;
import com.google.api.gax.tracing.ApiTracer;
import com.google.api.gax.tracing.ApiTracerFactory;
import com.google.api.gax.tracing.OpencensusTracerFactory;
import com.google.api.gax.tracing.SpanName;
import org.threeten.bp.Duration;

/**
* Simple wrapper around {@link ApiTracerFactory} to augment the client name of the generated
Expand Down

0 comments on commit 8579ac1

Please sign in to comment.