Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix batcher metric labels #1829

Merged
merged 5 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ If you are using Maven without the BOM, add this to your dependencies:
If you are using Gradle 5.x or later, add this to your dependencies:

```Groovy
implementation platform('com.google.cloud:libraries-bom:26.18.0')
implementation platform('com.google.cloud:libraries-bom:26.20.0')

implementation 'com.google.cloud:google-cloud-bigtable'
```
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-bigtable:2.24.1'
implementation 'com.google.cloud:google-cloud-bigtable:2.25.1'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-bigtable" % "2.24.1"
libraryDependencies += "com.google.cloud" % "google-cloud-bigtable" % "2.25.1"
```
<!-- {x-version-update-end} -->

Expand Down Expand Up @@ -609,7 +609,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigtable/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigtable.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigtable/2.24.1
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigtable/2.25.1
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
5 changes: 5 additions & 0 deletions google-cloud-bigtable/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,9 @@
<className>com/google/cloud/bigtable/data/v2/stub/readrows/RowMerger</className>
<method>*</method>
</difference>
<!-- InternalApi was removed -->
<difference>
<differenceType>8001</differenceType>
<className>com/google/cloud/bigtable/data/v2/stub/metrics/BigtableTracerBatchedUnaryCallable</className>
</difference>
</differences>
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
import com.google.cloud.bigtable.data.v2.stub.changestream.GenerateInitialChangeStreamPartitionsUserCallable;
import com.google.cloud.bigtable.data.v2.stub.changestream.ReadChangeStreamResumptionStrategy;
import com.google.cloud.bigtable.data.v2.stub.changestream.ReadChangeStreamUserCallable;
import com.google.cloud.bigtable.data.v2.stub.metrics.BigtableTracerBatchedUnaryCallable;
import com.google.cloud.bigtable.data.v2.stub.metrics.BigtableTracerStreamingCallable;
import com.google.cloud.bigtable.data.v2.stub.metrics.BigtableTracerUnaryCallable;
import com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsTracerFactory;
Expand Down Expand Up @@ -509,11 +508,8 @@ private <RowT> UnaryCallable<Query, List<RowT>> createBulkReadRowsCallable(
UnaryCallable<Query, List<RowT>> tracedBatcher =
new TracedBatcherUnaryCallable<>(readRowsUserCallable.all());

UnaryCallable<Query, List<RowT>> withBigtableTracer =
new BigtableTracerBatchedUnaryCallable<>(tracedBatcher);

UnaryCallable<Query, List<RowT>> traced =
new TracedUnaryCallable<>(withBigtableTracer, clientContext.getTracerFactory(), span);
new TracedUnaryCallable<>(tracedBatcher, clientContext.getTracerFactory(), span);

return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Expand Down Expand Up @@ -641,10 +637,9 @@ private UnaryCallable<BulkMutation, Void> createBulkMutateRowsCallable() {
UnaryCallable<BulkMutation, Void> tracedBatcherUnaryCallable =
new TracedBatcherUnaryCallable<>(userFacing);

UnaryCallable<BulkMutation, Void> withBigtableTracer =
new BigtableTracerBatchedUnaryCallable<>(tracedBatcherUnaryCallable);
UnaryCallable<BulkMutation, Void> traced =
new TracedUnaryCallable<>(withBigtableTracer, clientContext.getTracerFactory(), spanName);
new TracedUnaryCallable<>(
tracedBatcherUnaryCallable, clientContext.getTracerFactory(), spanName);

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

ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> withBigtableTracer =
new BigtableTracerStreamingCallable<>(convertException);

RetryAlgorithm<Void> retryAlgorithm =
new RetryAlgorithm<>(
new ApiResultRetryAlgorithm<Void>(),
Expand All @@ -757,7 +755,7 @@ public Map<String, String> extract(MutateRowsRequest mutateRowsRequest) {

return new MutateRowsRetryingCallable(
clientContext.getDefaultCallContext(),
convertException,
withBigtableTracer,
retryingExecutor,
settings.bulkMutateRowsSettings().getRetryableCodes());
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ApiFuture<ResponseT> futureCall(RequestT request, ApiCallContext context)
}
}

class BigtableTracerUnaryCallback<ResponseT> implements ApiFutureCallback<ResponseT> {
private class BigtableTracerUnaryCallback<ResponseT> implements ApiFutureCallback<ResponseT> {

private final BigtableTracer tracer;
private final GrpcResponseMetadata responseMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,16 @@ public void testBatchBlockingLatencies() throws InterruptedException {
verify(statsRecorderWrapper, timeout(1000).times(expectedNumRequests))
.putClientBlockingLatencies(throttledTime.capture());

// Adding the first 2 elements should not get throttled since the batch is empty
assertThat(throttledTime.getAllValues().get(0)).isEqualTo(0);
// After the first request is sent, batcher will block on add because of the server latency.
// Blocking latency should be around server latency.
assertThat(throttledTime.getAllValues().get(1)).isAtLeast(SERVER_LATENCY - 10);
assertThat(throttledTime.getAllValues().get(2)).isAtLeast(SERVER_LATENCY - 10);

verify(statsRecorderWrapper, timeout(100).times(expectedNumRequests))
.recordAttempt(status.capture(), tableId.capture(), zone.capture(), cluster.capture());

assertThat(zone.getAllValues()).containsExactly(ZONE, ZONE, ZONE);
assertThat(cluster.getAllValues()).containsExactly(CLUSTER, CLUSTER, CLUSTER);
}
}

Expand Down