Skip to content

Commit

Permalink
Fix formatting issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkaregar committed Jan 24, 2024
1 parent d635049 commit ffe5c2f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public StatsRecorderWrapper(
this.operationMeasureMap = statsRecorder.newMeasureMap();
}

public void recordOperation(String status, String tableId, String zone, String cluster, String clientVersion) {
public void recordOperation(
String status, String tableId, String zone, String cluster, String clientVersion) {
TagContextBuilder tagCtx =
newTagContextBuilder(tableId, zone, cluster, clientVersion)
.putLocal(BuiltinMeasureConstants.STATUS, TagValue.create(status));
Expand All @@ -73,7 +74,8 @@ public void recordOperation(String status, String tableId, String zone, String c
operationMeasureMap = statsRecorder.newMeasureMap();
}

public void recordAttempt(String status, String tableId, String zone, String cluster, String clientVersion) {
public void recordAttempt(
String status, String tableId, String zone, String cluster, String clientVersion) {
TagContextBuilder tagCtx =
newTagContextBuilder(tableId, zone, cluster, clientVersion)
.putLocal(BuiltinMeasureConstants.STATUS, TagValue.create(status));
Expand Down Expand Up @@ -119,12 +121,14 @@ public void putClientBlockingLatencies(long clientBlockingLatency) {
operationMeasureMap.put(BuiltinMeasureConstants.THROTTLING_LATENCIES, clientBlockingLatency);
}

private TagContextBuilder newTagContextBuilder(String tableId, String zone, String cluster, String clientVersion) {
private TagContextBuilder newTagContextBuilder(
String tableId, String zone, String cluster, String clientVersion) {
TagContextBuilder tagContextBuilder =
tagger
.toBuilder(parentContext)
.putLocal(BuiltinMeasureConstants.CLIENT_NAME, TagValue.create(
"bigtable-java/" + clientVersion))
.putLocal(
BuiltinMeasureConstants.CLIENT_NAME,
TagValue.create("bigtable-java/" + clientVersion))
.putLocal(BuiltinMeasureConstants.METHOD, TagValue.create(spanName.toString()))
.putLocal(BuiltinMeasureConstants.TABLE, TagValue.create(tableId))
.putLocal(BuiltinMeasureConstants.ZONE, TagValue.create(zone))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import com.google.api.gax.retrying.ServerStreamingAttemptException;
import com.google.api.gax.tracing.SpanName;
import com.google.cloud.bigtable.stats.StatsRecorderWrapper;
import com.google.cloud.bigtable.Version;
import com.google.cloud.bigtable.stats.StatsRecorderWrapper;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Stopwatch;
import com.google.common.math.IntMath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,13 @@ public void testReadRowsOperationLatencies() {

verify(statsRecorderWrapper).putOperationLatencies(operationLatency.capture());
// verify record operation is only called once
verify(statsRecorderWrapper).recordOperation(
status.capture(), tableId.capture(), zone.capture(), cluster.capture(), version.capture());
verify(statsRecorderWrapper)
.recordOperation(
status.capture(),
tableId.capture(),
zone.capture(),
cluster.capture(),
version.capture());

assertThat(operationLatency.getValue()).isIn(Range.closed(SERVER_LATENCY, elapsed));
assertThat(status.getAllValues()).containsExactly("OK");
Expand All @@ -289,8 +294,13 @@ public void testGfeMetrics() {
Lists.newArrayList(stub.readRowsCallable().call(Query.create(TABLE_ID)));

// Verify record attempt are called multiple times
verify(statsRecorderWrapper, times(fakeService.getAttemptCounter().get())).recordAttempt(
status.capture(), tableId.capture(), zone.capture(), cluster.capture(), version.capture());
verify(statsRecorderWrapper, times(fakeService.getAttemptCounter().get()))
.recordAttempt(
status.capture(),
tableId.capture(),
zone.capture(),
cluster.capture(),
version.capture());

// The request was retried and gfe latency is only recorded in the retry attempt
verify(statsRecorderWrapper).putGfeLatencies(gfeLatency.capture());
Expand Down Expand Up @@ -355,8 +365,13 @@ public void onComplete() {

verify(statsRecorderWrapper).putApplicationLatencies(applicationLatency.capture());
verify(statsRecorderWrapper).putOperationLatencies(operationLatency.capture());
verify(statsRecorderWrapper).recordOperation(
status.capture(), tableId.capture(), zone.capture(), cluster.capture(), version.capture());
verify(statsRecorderWrapper)
.recordOperation(
status.capture(),
tableId.capture(),
zone.capture(),
cluster.capture(),
version.capture());

assertThat(counter.get()).isEqualTo(fakeService.getResponseCounter().get());
// Thread.sleep might not sleep for the requested amount depending on the interrupt period
Expand Down Expand Up @@ -394,8 +409,13 @@ public void testReadRowsApplicationLatencyWithManualFlowControl() throws Excepti

verify(statsRecorderWrapper).putApplicationLatencies(applicationLatency.capture());
verify(statsRecorderWrapper).putOperationLatencies(operationLatency.capture());
verify(statsRecorderWrapper).recordOperation(
status.capture(), tableId.capture(), zone.capture(), cluster.capture(), version.capture());
verify(statsRecorderWrapper)
.recordOperation(
status.capture(),
tableId.capture(),
zone.capture(),
cluster.capture(),
version.capture());

// For manual flow control, the last application latency shouldn't count, because at that point
// the server already sent back all the responses.
Expand Down Expand Up @@ -448,9 +468,13 @@ public void testMutateRowAttemptsTagValues() {
// calls releaseWaiters(). onOperationComplete() is called in TracerFinisher which will be
// called after the mutateRow call is returned. So there's a race between when the call returns
// and when the record() is called in onOperationCompletion().
verify(statsRecorderWrapper, timeout(50).times(
fakeService.getAttemptCounter().get())).recordAttempt(
status.capture(), tableId.capture(), zone.capture(), cluster.capture(), version.capture());
verify(statsRecorderWrapper, timeout(50).times(fakeService.getAttemptCounter().get()))
.recordAttempt(
status.capture(),
tableId.capture(),
zone.capture(),
cluster.capture(),
version.capture());
assertThat(zone.getAllValues()).containsExactly("global", "global", ZONE);
assertThat(cluster.getAllValues()).containsExactly("unspecified", "unspecified", CLUSTER);
assertThat(status.getAllValues()).containsExactly("UNAVAILABLE", "UNAVAILABLE", "OK");
Expand All @@ -474,9 +498,13 @@ public void testReadRowsAttemptsTagValues() {
// calls releaseWaiters(). onOperationComplete() is called in TracerFinisher which will be
// called after the mutateRow call is returned. So there's a race between when the call returns
// and when the record() is called in onOperationCompletion().
verify(statsRecorderWrapper, timeout(50).times(
fakeService.getAttemptCounter().get())).recordAttempt(
status.capture(), tableId.capture(), zone.capture(), cluster.capture(), version.capture());
verify(statsRecorderWrapper, timeout(50).times(fakeService.getAttemptCounter().get()))
.recordAttempt(
status.capture(),
tableId.capture(),
zone.capture(),
cluster.capture(),
version.capture());
assertThat(zone.getAllValues()).containsExactly("global", ZONE);
assertThat(cluster.getAllValues()).containsExactly("unspecified", CLUSTER);
assertThat(status.getAllValues()).containsExactly("UNAVAILABLE", "OK");
Expand Down Expand Up @@ -507,8 +535,13 @@ public void testBatchBlockingLatencies() throws InterruptedException {
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(), version.capture());
verify(statsRecorderWrapper, timeout(100).times(expectedNumRequests))
.recordAttempt(
status.capture(),
tableId.capture(),
zone.capture(),
cluster.capture(),
version.capture());

assertThat(zone.getAllValues()).containsExactly(ZONE, ZONE, ZONE);
assertThat(cluster.getAllValues()).containsExactly(CLUSTER, CLUSTER, CLUSTER);
Expand Down Expand Up @@ -572,8 +605,13 @@ public void testPermanentFailure() {

verify(statsRecorderWrapper, timeout(50)).putAttemptLatencies(attemptLatency.capture());
verify(statsRecorderWrapper, timeout(50)).putOperationLatencies(operationLatency.capture());
verify(statsRecorderWrapper, timeout(50)).recordAttempt(
status.capture(), tableId.capture(), zone.capture(), cluster.capture(), version.capture());
verify(statsRecorderWrapper, timeout(50))
.recordAttempt(
status.capture(),
tableId.capture(),
zone.capture(),
cluster.capture(),
version.capture());

assertThat(status.getValue()).isEqualTo("NOT_FOUND");
assertThat(tableId.getValue()).isEqualTo(BAD_TABLE_ID);
Expand Down

0 comments on commit ffe5c2f

Please sign in to comment.