|
64 | 64 | import com.google.cloud.grpc.GrpcTransportOptions;
|
65 | 65 | import com.google.cloud.spanner.AdminRequestsPerMinuteExceededException;
|
66 | 66 | import com.google.cloud.spanner.BackupId;
|
67 |
| -import com.google.cloud.spanner.BuiltInMetricsConstant; |
68 | 67 | import com.google.cloud.spanner.ErrorCode;
|
69 | 68 | import com.google.cloud.spanner.Restore;
|
70 | 69 | import com.google.cloud.spanner.SpannerException;
|
|
87 | 86 | import com.google.common.base.Function;
|
88 | 87 | import com.google.common.base.MoreObjects;
|
89 | 88 | import com.google.common.base.Preconditions;
|
| 89 | +import com.google.common.base.Supplier; |
| 90 | +import com.google.common.base.Suppliers; |
90 | 91 | import com.google.common.collect.ImmutableList;
|
91 | 92 | import com.google.common.collect.ImmutableSet;
|
92 | 93 | import com.google.common.io.Resources;
|
@@ -278,6 +279,11 @@ public class GapicSpannerRpc implements SpannerRpc {
|
278 | 279 | private final int numChannels;
|
279 | 280 | private final boolean isGrpcGcpExtensionEnabled;
|
280 | 281 |
|
| 282 | + private Supplier<Boolean> directPathEnabledSupplier = |
| 283 | + () -> { |
| 284 | + return false; |
| 285 | + };; |
| 286 | + |
281 | 287 | public static GapicSpannerRpc create(SpannerOptions options) {
|
282 | 288 | return new GapicSpannerRpc(options);
|
283 | 289 | }
|
@@ -353,7 +359,9 @@ public GapicSpannerRpc(final SpannerOptions options) {
|
353 | 359 | SpannerInterceptorProvider.create(
|
354 | 360 | MoreObjects.firstNonNull(
|
355 | 361 | options.getInterceptorProvider(),
|
356 |
| - SpannerInterceptorProvider.createDefault(options.getOpenTelemetry()))) |
| 362 | + SpannerInterceptorProvider.createDefault( |
| 363 | + options.getOpenTelemetry(), |
| 364 | + (() -> directPathEnabledSupplier.get())))) |
357 | 365 | // This sets the trace context headers.
|
358 | 366 | .withTraceContext(endToEndTracingEnabled, options.getOpenTelemetry())
|
359 | 367 | // This sets the response compressor (Server -> Client).
|
@@ -411,9 +419,12 @@ public GapicSpannerRpc(final SpannerOptions options) {
|
411 | 419 | .build();
|
412 | 420 | ClientContext clientContext = ClientContext.create(spannerStubSettings);
|
413 | 421 | this.spannerStub = GrpcSpannerStubWrapper.create(spannerStubSettings, clientContext);
|
414 |
| - BuiltInMetricsConstant.DIRECT_PATH_ENABLED = |
415 |
| - ((GrpcTransportChannel) clientContext.getTransportChannel()).isDirectPath() |
416 |
| - && isAttemptDirectPathXds; |
| 422 | + this.directPathEnabledSupplier = |
| 423 | + Suppliers.memoize( |
| 424 | + () -> { |
| 425 | + return ((GrpcTransportChannel) clientContext.getTransportChannel()).isDirectPath() |
| 426 | + && isAttemptDirectPathXds; |
| 427 | + }); |
417 | 428 | this.readRetrySettings =
|
418 | 429 | options.getSpannerStubSettings().streamingReadSettings().getRetrySettings();
|
419 | 430 | this.readRetryableCodes =
|
|
0 commit comments