Skip to content

Commit 6245c12

Browse files
authored
fix: fix batcher metric labels (#1829)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-bigtable/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> ☕️ If you write sample code, please follow the [samples format]( https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
1 parent 3c53775 commit 6245c12

File tree

5 files changed

+19
-67
lines changed

5 files changed

+19
-67
lines changed

google-cloud-bigtable/clirr-ignored-differences.xml

+5
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,9 @@
145145
<className>com/google/cloud/bigtable/data/v2/stub/readrows/RowMerger</className>
146146
<method>*</method>
147147
</difference>
148+
<!-- InternalApi was removed -->
149+
<difference>
150+
<differenceType>8001</differenceType>
151+
<className>com/google/cloud/bigtable/data/v2/stub/metrics/BigtableTracerBatchedUnaryCallable</className>
152+
</difference>
148153
</differences>

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
import com.google.cloud.bigtable.data.v2.stub.changestream.GenerateInitialChangeStreamPartitionsUserCallable;
8888
import com.google.cloud.bigtable.data.v2.stub.changestream.ReadChangeStreamResumptionStrategy;
8989
import com.google.cloud.bigtable.data.v2.stub.changestream.ReadChangeStreamUserCallable;
90-
import com.google.cloud.bigtable.data.v2.stub.metrics.BigtableTracerBatchedUnaryCallable;
9190
import com.google.cloud.bigtable.data.v2.stub.metrics.BigtableTracerStreamingCallable;
9291
import com.google.cloud.bigtable.data.v2.stub.metrics.BigtableTracerUnaryCallable;
9392
import com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsTracerFactory;
@@ -509,11 +508,8 @@ private <RowT> UnaryCallable<Query, List<RowT>> createBulkReadRowsCallable(
509508
UnaryCallable<Query, List<RowT>> tracedBatcher =
510509
new TracedBatcherUnaryCallable<>(readRowsUserCallable.all());
511510

512-
UnaryCallable<Query, List<RowT>> withBigtableTracer =
513-
new BigtableTracerBatchedUnaryCallable<>(tracedBatcher);
514-
515511
UnaryCallable<Query, List<RowT>> traced =
516-
new TracedUnaryCallable<>(withBigtableTracer, clientContext.getTracerFactory(), span);
512+
new TracedUnaryCallable<>(tracedBatcher, clientContext.getTracerFactory(), span);
517513

518514
return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
519515
}
@@ -641,10 +637,9 @@ private UnaryCallable<BulkMutation, Void> createBulkMutateRowsCallable() {
641637
UnaryCallable<BulkMutation, Void> tracedBatcherUnaryCallable =
642638
new TracedBatcherUnaryCallable<>(userFacing);
643639

644-
UnaryCallable<BulkMutation, Void> withBigtableTracer =
645-
new BigtableTracerBatchedUnaryCallable<>(tracedBatcherUnaryCallable);
646640
UnaryCallable<BulkMutation, Void> traced =
647-
new TracedUnaryCallable<>(withBigtableTracer, clientContext.getTracerFactory(), spanName);
641+
new TracedUnaryCallable<>(
642+
tracedBatcherUnaryCallable, clientContext.getTracerFactory(), spanName);
648643

649644
return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
650645
}
@@ -747,6 +742,9 @@ public Map<String, String> extract(MutateRowsRequest mutateRowsRequest) {
747742
ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> convertException =
748743
new ConvertExceptionCallable<>(callable);
749744

745+
ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> withBigtableTracer =
746+
new BigtableTracerStreamingCallable<>(convertException);
747+
750748
RetryAlgorithm<Void> retryAlgorithm =
751749
new RetryAlgorithm<>(
752750
new ApiResultRetryAlgorithm<Void>(),
@@ -757,7 +755,7 @@ public Map<String, String> extract(MutateRowsRequest mutateRowsRequest) {
757755

758756
return new MutateRowsRetryingCallable(
759757
clientContext.getDefaultCallContext(),
760-
convertException,
758+
withBigtableTracer,
761759
retryingExecutor,
762760
settings.bulkMutateRowsSettings().getRetryableCodes());
763761
}

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableTracerBatchedUnaryCallable.java

-55
This file was deleted.

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableTracerUnaryCallable.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public ApiFuture<ResponseT> futureCall(RequestT request, ApiCallContext context)
7070
}
7171
}
7272

73-
class BigtableTracerUnaryCallback<ResponseT> implements ApiFutureCallback<ResponseT> {
73+
private class BigtableTracerUnaryCallback<ResponseT> implements ApiFutureCallback<ResponseT> {
7474

7575
private final BigtableTracer tracer;
7676
private final GrpcResponseMetadata responseMetadata;

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,16 @@ public void testBatchBlockingLatencies() throws InterruptedException {
491491
verify(statsRecorderWrapper, timeout(1000).times(expectedNumRequests))
492492
.putClientBlockingLatencies(throttledTime.capture());
493493

494-
// Adding the first 2 elements should not get throttled since the batch is empty
495-
assertThat(throttledTime.getAllValues().get(0)).isEqualTo(0);
496494
// After the first request is sent, batcher will block on add because of the server latency.
497495
// Blocking latency should be around server latency.
498496
assertThat(throttledTime.getAllValues().get(1)).isAtLeast(SERVER_LATENCY - 10);
499497
assertThat(throttledTime.getAllValues().get(2)).isAtLeast(SERVER_LATENCY - 10);
498+
499+
verify(statsRecorderWrapper, timeout(100).times(expectedNumRequests))
500+
.recordAttempt(status.capture(), tableId.capture(), zone.capture(), cluster.capture());
501+
502+
assertThat(zone.getAllValues()).containsExactly(ZONE, ZONE, ZONE);
503+
assertThat(cluster.getAllValues()).containsExactly(CLUSTER, CLUSTER, CLUSTER);
500504
}
501505
}
502506

0 commit comments

Comments
 (0)