Skip to content

Commit

Permalink
fix: fix connectivity error count calculation (#1632)
Browse files Browse the repository at this point in the history
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://togithub.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://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
  • Loading branch information
mutianf committed Feb 16, 2023
1 parent 0865023 commit 0803785
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ class BuiltinMetricsTracer extends BigtableTracer {
private String zone = "global";
private String cluster = "unspecified";

// gfe stats
private AtomicLong gfeMissingHeaders = new AtomicLong(0);

@VisibleForTesting
BuiltinMetricsTracer(
OperationType operationType, SpanName spanName, StatsRecorderWrapper recorder) {
Expand Down Expand Up @@ -208,10 +205,10 @@ public void recordGfeMetadata(@Nullable Long latency, @Nullable Throwable throwa
// zone information
if (latency != null) {
recorder.putGfeLatencies(latency);
recorder.putGfeMissingHeaders(0);
} else {
gfeMissingHeaders.incrementAndGet();
recorder.putGfeMissingHeaders(1);
}
recorder.putGfeMissingHeaders(gfeMissingHeaders.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void testGfeMetrics() {
// The first time the request was retried, it'll increment missing header counter
verify(statsRecorderWrapper, times(fakeService.getAttemptCounter().get()))
.putGfeMissingHeaders(gfeMissingHeaders.capture());
assertThat(gfeMissingHeaders.getValue()).isEqualTo(1);
assertThat(gfeMissingHeaders.getAllValues()).containsExactly(1L, 0L);

assertThat(status.getAllValues()).containsExactly("UNAVAILABLE", "OK");
assertThat(tableId.getAllValues()).containsExactly(TABLE_ID, TABLE_ID);
Expand Down

0 comments on commit 0803785

Please sign in to comment.