From 4f12ea4b36ec0594acee3304ff320e9b799b52f6 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Wed, 18 Feb 2026 15:52:13 -0500 Subject: [PATCH] fix: ensure that per attempt metrics tracer is below the retries Change-Id: Idc58fa55bdb34a1e85fff6685c043bf559655e84 --- .../data/v2/stub/EnhancedBigtableStub.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java index cf8b65684e..e756e41f02 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java @@ -695,10 +695,10 @@ public ApiFuture> futureCall(String s, ApiCallContext apiCallCon withStatsHeaders = new StatsHeadersUnaryCallable<>(spoolable); UnaryCallable> - withBigtableTracer = new BigtableTracerUnaryCallable<>(withStatsHeaders); + withAttemptTracer = new BigtableTracerUnaryCallable<>(withStatsHeaders); UnaryCallable> - retryable = withRetries(withBigtableTracer, settings.sampleRowKeysSettings()); + retryable = withRetries(withAttemptTracer, settings.sampleRowKeysSettings()); return createUserFacingUnaryCallable( methodName, @@ -774,7 +774,7 @@ private UnaryCallable createMutateRowsBas ServerStreamingCallable convertException = new ConvertExceptionCallable<>(callable); - ServerStreamingCallable withBigtableTracer = + ServerStreamingCallable withAttemptTracer = new BigtableTracerStreamingCallable<>(convertException); BasicResultRetryAlgorithm resultRetryAlgorithm; @@ -797,7 +797,7 @@ private UnaryCallable createMutateRowsBas UnaryCallable baseCallable = new MutateRowsRetryingCallable( clientContext.getDefaultCallContext(), - withBigtableTracer, + withAttemptTracer, retryingExecutor, settings.bulkMutateRowsSettings().getRetryableCodes(), retryAlgorithm); @@ -1033,11 +1033,11 @@ private UnaryCallable createReadModifyWriteRowCallable( ServerStreamingCallable watched = Callables.watched(convertException, innerSettings, clientContext); - ServerStreamingCallable withBigtableTracer = + ServerStreamingCallable withAttemptTracer = new BigtableTracerStreamingCallable<>(watched); ServerStreamingCallable retrying = - withRetries(withBigtableTracer, innerSettings); + withRetries(withAttemptTracer, innerSettings); SpanName span = getSpanName("GenerateInitialChangeStreamPartitions"); ServerStreamingCallable traced = @@ -1105,11 +1105,11 @@ private UnaryCallable createReadModifyWriteRowCallable( ServerStreamingCallable watched = Callables.watched(merging, innerSettings, clientContext); - ServerStreamingCallable withBigtableTracer = + ServerStreamingCallable withAttemptTracer = new BigtableTracerStreamingCallable<>(watched); ServerStreamingCallable readChangeStreamCallable = - withRetries(withBigtableTracer, innerSettings); + withRetries(withAttemptTracer, innerSettings); ServerStreamingCallable readChangeStreamUserCallable = @@ -1175,6 +1175,9 @@ public Map extract(ExecuteQueryRequest executeQueryRequest) { ServerStreamingCallable convertException = new ConvertExceptionCallable<>(withPlanRefresh); + ServerStreamingCallable withAttemptTracer = + new BigtableTracerStreamingCallable<>(convertException); + ServerStreamingCallSettings retrySettings = ServerStreamingCallSettings.newBuilder() .setResumptionStrategy(new ExecuteQueryResumptionStrategy()) @@ -1189,7 +1192,7 @@ public Map extract(ExecuteQueryRequest executeQueryRequest) { // attempt stream will have reset set to true, so any unyielded data from the previous // attempt will be reset properly ServerStreamingCallable retries = - withRetries(convertException, retrySettings); + withRetries(withAttemptTracer, retrySettings); ServerStreamingCallable merging = new SqlRowMergingCallable(retries); @@ -1208,13 +1211,10 @@ public Map extract(ExecuteQueryRequest executeQueryRequest) { ServerStreamingCallable passingThroughErrorsToMetadata = new MetadataErrorHandlingCallable(watched); - ServerStreamingCallable withBigtableTracer = - new BigtableTracerStreamingCallable<>(passingThroughErrorsToMetadata); - SpanName span = getSpanName("ExecuteQuery"); ServerStreamingCallable traced = new TracedServerStreamingCallable<>( - withBigtableTracer, clientContext.getTracerFactory(), span); + passingThroughErrorsToMetadata, clientContext.getTracerFactory(), span); return new ExecuteQueryCallable( traced.withDefaultCallContext(