5555import io .grpc .Status ;
5656import io .grpc .StatusRuntimeException ;
5757import io .grpc .stub .StreamObserver ;
58- import io .opencensus .impl . stats .StatsComponentImpl ;
58+ import io .opencensus .stats .StatsComponent ;
5959import io .opencensus .tags .TagKey ;
6060import io .opencensus .tags .TagValue ;
6161import io .opencensus .tags .Tags ;
@@ -105,7 +105,7 @@ public class MetricsTracerTest {
105105 @ Mock (answer = Answers .CALLS_REAL_METHODS )
106106 private BigtableGrpc .BigtableImplBase mockService ;
107107
108- private final StatsComponentImpl localStats = new StatsComponentImpl ();
108+ private final StatsComponent localStats = new SimpleStatsComponent ();
109109 private EnhancedBigtableStub stub ;
110110 private BigtableDataSettings settings ;
111111
@@ -157,9 +157,6 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
157157 Lists .newArrayList (stub .readRowsCallable ().call (Query .create (TABLE_ID )));
158158 long elapsed = stopwatch .elapsed (TimeUnit .MILLISECONDS );
159159
160- // Give OpenCensus a chance to update the views asynchronously.
161- Thread .sleep (100 );
162-
163160 long opLatency =
164161 StatsTestUtils .getAggregationValueAsLong (
165162 localStats ,
@@ -193,9 +190,6 @@ public Object answer(InvocationOnMock invocation) {
193190 Lists .newArrayList (stub .readRowsCallable ().call (Query .create (TABLE_ID )));
194191 Lists .newArrayList (stub .readRowsCallable ().call (Query .create (TABLE_ID )));
195192
196- // Give OpenCensus a chance to update the views asynchronously.
197- Thread .sleep (100 );
198-
199193 long opLatency =
200194 StatsTestUtils .getAggregationValueAsLong (
201195 localStats ,
@@ -247,8 +241,6 @@ public void testReadRowsFirstRow() throws InterruptedException {
247241 }
248242 long elapsed = stopwatch .elapsed (TimeUnit .MILLISECONDS );
249243
250- // Give OpenCensus a chance to update the views asynchronously.
251- Thread .sleep (100 );
252244 executor .shutdown ();
253245
254246 long firstRowLatency =
@@ -292,9 +284,6 @@ public Object answer(InvocationOnMock invocation) {
292284
293285 Lists .newArrayList (stub .readRowsCallable ().call (Query .create (TABLE_ID )));
294286
295- // Give OpenCensus a chance to update the views asynchronously.
296- Thread .sleep (100 );
297-
298287 long opLatency =
299288 StatsTestUtils .getAggregationValueAsLong (
300289 localStats ,
@@ -341,9 +330,6 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
341330 Lists .newArrayList (stub .readRowsCallable ().call (Query .create (TABLE_ID )));
342331 long elapsed = stopwatch .elapsed (TimeUnit .MILLISECONDS );
343332
344- // Give OpenCensus a chance to update the views asynchronously.
345- Thread .sleep (100 );
346-
347333 long attemptLatency =
348334 StatsTestUtils .getAggregationValueAsLong (
349335 localStats ,
@@ -360,12 +346,11 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
360346 }
361347
362348 @ Test
363- public void testInvalidRequest () throws InterruptedException {
349+ public void testInvalidRequest () {
364350 try {
365351 stub .bulkMutateRowsCallable ().call (BulkMutation .create (TABLE_ID ));
366352 Assert .fail ("Invalid request should throw exception" );
367353 } catch (IllegalStateException e ) {
368- Thread .sleep (100 );
369354 // Verify that the latency is recorded with an error code (in this case UNKNOWN)
370355 long attemptLatency =
371356 StatsTestUtils .getAggregationValueAsLong (
@@ -403,9 +388,6 @@ public Object answer(InvocationOnMock invocation) {
403388 batcher .add (ByteString .copyFromUtf8 ("row1" ));
404389 batcher .sendOutstanding ();
405390
406- // Give OpenCensus a chance to update the views asynchronously.
407- Thread .sleep (100 );
408-
409391 long throttledTimeMetric =
410392 StatsTestUtils .getAggregationValueAsLong (
411393 localStats ,
@@ -471,7 +453,6 @@ public Object answer(InvocationOnMock invocation) {
471453 batcher .add (RowMutationEntry .create ("key" ));
472454 batcher .sendOutstanding ();
473455
474- Thread .sleep (100 );
475456 long throttledTimeMetric =
476457 StatsTestUtils .getAggregationValueAsLong (
477458 localStats ,
0 commit comments