Skip to content

Commit

Permalink
clean up statsRecorder
Browse files Browse the repository at this point in the history
  • Loading branch information
mutianf committed Feb 29, 2024
1 parent f3abda3 commit 6eb366a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.PER_CONNECTION_ERROR_COUNT_NAME;

import com.google.api.core.InternalApi;
import com.google.cloud.bigtable.stats.StatsRecorderWrapperForConnection;
import com.google.common.annotations.VisibleForTesting;
import io.grpc.ClientInterceptor;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.Attributes;
Expand All @@ -42,14 +40,6 @@ public class ErrorCountPerConnectionMetricTracker implements Runnable {

private final Set<ConnectionErrorCountInterceptor> connectionErrorCountInterceptors;
private final Object interceptorsLock = new Object();
// This is not final so that it can be updated and mocked during testing.
private StatsRecorderWrapperForConnection statsRecorderWrapperForConnection;

@VisibleForTesting
void setStatsRecorderWrapperForConnection(
StatsRecorderWrapperForConnection statsRecorderWrapperForConnection) {
this.statsRecorderWrapperForConnection = statsRecorderWrapperForConnection;
}

public ErrorCountPerConnectionMetricTracker(OpenTelemetry openTelemetry, Attributes attributes) {
connectionErrorCountInterceptors =
Expand Down Expand Up @@ -93,7 +83,6 @@ public void run() {
if (errors > 0 || successes > 0) {
// TODO: add a metric to also keep track of the number of successful requests per each
// connection.
statsRecorderWrapperForConnection.putAndRecordPerConnectionErrorCount(errors);
perConnectionErrorCountHistogram.record(errors, attributes);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.cloud.bigtable.data.v2.models.*;
import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStub;
import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStubSettings;
import com.google.cloud.bigtable.stats.StatsRecorderWrapperForConnection;
import io.grpc.Server;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
Expand Down Expand Up @@ -63,7 +62,6 @@ public class ErrorCountPerConnectionTest {
private final FakeService fakeService = new FakeService();
private EnhancedBigtableStubSettings.Builder builder;
private ArgumentCaptor<Runnable> runnableCaptor;
private StatsRecorderWrapperForConnection statsRecorderWrapperForConnection;

private InMemoryMetricReader metricReader;

Expand Down Expand Up @@ -108,8 +106,6 @@ public void setup() throws Exception {
Mockito.when(
executors.scheduleAtFixedRate(runnableCaptor.capture(), anyLong(), anyLong(), any()))
.thenReturn(null);

statsRecorderWrapperForConnection = Mockito.mock(StatsRecorderWrapperForConnection.class);
}

@After
Expand Down Expand Up @@ -298,8 +294,6 @@ private void runInterceptorTasksAndAssertCount() {
int actualNumOfTasks = 0;
for (Runnable runnable : runnableCaptor.getAllValues()) {
if (runnable instanceof ErrorCountPerConnectionMetricTracker) {
((ErrorCountPerConnectionMetricTracker) runnable)
.setStatsRecorderWrapperForConnection(statsRecorderWrapperForConnection);
runnable.run();
actualNumOfTasks++;
}
Expand Down

0 comments on commit 6eb366a

Please sign in to comment.