@@ -149,10 +149,10 @@ void retry() {
149
149
HttpJsonCallableFactory .createUnaryCallable (
150
150
callInt , callSettings , httpJsonCallSettings , clientContext );
151
151
assertThat (callable .call (initialRequest )).isEqualTo (2 );
152
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isEqualTo (3 );
153
- assertThat (tracerFactory .getTracerAttempts ().get ()).isEqualTo (4 );
154
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isFalse ();
155
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isFalse ();
152
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isEqualTo (3 );
153
+ assertThat (tracerFactory .getInstance (). getAttemptsStarted ().get ()).isEqualTo (4 );
154
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isFalse ();
155
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isFalse ();
156
156
157
157
// Capture the argument passed to futureCall
158
158
ArgumentCaptor <Integer > argumentCaptor = ArgumentCaptor .forClass (Integer .class );
@@ -190,10 +190,10 @@ void retryTotalTimeoutExceeded() {
190
190
HttpJsonCallableFactory .createUnaryCallable (
191
191
callInt , callSettings , httpJsonCallSettings , clientContext );
192
192
assertThrows (ApiException .class , () -> callable .call (initialRequest ));
193
- assertThat (tracerFactory .getTracerAttempts ().get ()).isEqualTo (1 );
194
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isEqualTo (0 );
195
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isFalse ();
196
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isTrue ();
193
+ assertThat (tracerFactory .getInstance (). getAttemptsStarted ().get ()).isEqualTo (1 );
194
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isEqualTo (0 );
195
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isFalse ();
196
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isTrue ();
197
197
// Capture the argument passed to futureCall
198
198
ArgumentCaptor <Integer > argumentCaptor = ArgumentCaptor .forClass (Integer .class );
199
199
verify (callInt , atLeastOnce ()).futureCall (argumentCaptor .capture (), any (ApiCallContext .class ));
@@ -214,10 +214,10 @@ void retryMaxAttemptsExceeded() {
214
214
HttpJsonCallableFactory .createUnaryCallable (
215
215
callInt , callSettings , httpJsonCallSettings , clientContext );
216
216
assertThrows (ApiException .class , () -> callable .call (initialRequest ));
217
- assertThat (tracerFactory .getTracerAttempts ().get ()).isEqualTo (2 );
218
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isEqualTo (1 );
219
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isTrue ();
220
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isTrue ();
217
+ assertThat (tracerFactory .getInstance (). getAttemptsStarted ().get ()).isEqualTo (2 );
218
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isEqualTo (1 );
219
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isTrue ();
220
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isTrue ();
221
221
// Capture the argument passed to futureCall
222
222
ArgumentCaptor <Integer > argumentCaptor = ArgumentCaptor .forClass (Integer .class );
223
223
verify (callInt , atLeastOnce ()).futureCall (argumentCaptor .capture (), any (ApiCallContext .class ));
@@ -238,10 +238,10 @@ void retryWithinMaxAttempts() {
238
238
HttpJsonCallableFactory .createUnaryCallable (
239
239
callInt , callSettings , httpJsonCallSettings , clientContext );
240
240
assertThat (callable .call (initialRequest )).isEqualTo (2 );
241
- assertThat (tracerFactory .getTracerAttempts ().get ()).isEqualTo (3 );
242
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isEqualTo (2 );
243
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isFalse ();
244
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isFalse ();
241
+ assertThat (tracerFactory .getInstance (). getAttemptsStarted ().get ()).isEqualTo (3 );
242
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isEqualTo (2 );
243
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isFalse ();
244
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isFalse ();
245
245
// Capture the argument passed to futureCall
246
246
ArgumentCaptor <Integer > argumentCaptor = ArgumentCaptor .forClass (Integer .class );
247
247
verify (callInt , atLeastOnce ()).futureCall (argumentCaptor .capture (), any (ApiCallContext .class ));
@@ -268,10 +268,10 @@ void retryOnStatusUnknown() {
268
268
HttpJsonCallableFactory .createUnaryCallable (
269
269
callInt , callSettings , httpJsonCallSettings , clientContext );
270
270
assertThat (callable .call (initialRequest )).isEqualTo (2 );
271
- assertThat (tracerFactory .getTracerAttempts ().get ()).isEqualTo (4 );
272
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isEqualTo (3 );
273
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isFalse ();
274
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isFalse ();
271
+ assertThat (tracerFactory .getInstance (). getAttemptsStarted ().get ()).isEqualTo (4 );
272
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isEqualTo (3 );
273
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isFalse ();
274
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isFalse ();
275
275
// Capture the argument passed to futureCall
276
276
ArgumentCaptor <Integer > argumentCaptor = ArgumentCaptor .forClass (Integer .class );
277
277
verify (callInt , atLeastOnce ()).futureCall (argumentCaptor .capture (), any (ApiCallContext .class ));
@@ -290,10 +290,10 @@ void retryOnUnexpectedException() {
290
290
HttpJsonCallableFactory .createUnaryCallable (
291
291
callInt , callSettings , httpJsonCallSettings , clientContext );
292
292
ApiException exception = assertThrows (ApiException .class , () -> callable .call (initialRequest ));
293
- assertThat (tracerFactory .getTracerAttempts ().get ()).isEqualTo (1 );
294
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isEqualTo (0 );
295
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isFalse ();
296
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isTrue ();
293
+ assertThat (tracerFactory .getInstance (). getAttemptsStarted ().get ()).isEqualTo (1 );
294
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isEqualTo (0 );
295
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isFalse ();
296
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isTrue ();
297
297
assertThat (exception ).hasCauseThat ().isSameInstanceAs (throwable );
298
298
// Capture the argument passed to futureCall
299
299
ArgumentCaptor <Integer > argumentCaptor = ArgumentCaptor .forClass (Integer .class );
@@ -323,10 +323,10 @@ void retryNoRecover() {
323
323
HttpJsonCallableFactory .createUnaryCallable (
324
324
callInt , callSettings , httpJsonCallSettings , clientContext );
325
325
ApiException exception = assertThrows (ApiException .class , () -> callable .call (initialRequest ));
326
- assertThat (tracerFactory .getTracerAttempts ().get ()).isEqualTo (1 );
327
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isEqualTo (0 );
328
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isFalse ();
329
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isTrue ();
326
+ assertThat (tracerFactory .getInstance (). getAttemptsStarted ().get ()).isEqualTo (1 );
327
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isEqualTo (0 );
328
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isFalse ();
329
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isTrue ();
330
330
assertThat (exception ).isSameInstanceAs (apiException );
331
331
// Capture the argument passed to futureCall
332
332
ArgumentCaptor <Integer > argumentCaptor = ArgumentCaptor .forClass (Integer .class );
@@ -356,11 +356,11 @@ void retryKeepFailing() {
356
356
// the number of attempts varies. Here we just make sure that all of them except the last are
357
357
// considered as failed
358
358
// attempts and that the operation was considered as failed.
359
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isGreaterThan (0 );
360
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ())
361
- .isEqualTo (tracerFactory .getTracerAttempts ().get () - 1 );
362
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isTrue ();
363
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isTrue ();
359
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isGreaterThan (0 );
360
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ())
361
+ .isEqualTo (tracerFactory .getInstance (). getAttemptsStarted ().get () - 1 );
362
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isTrue ();
363
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isTrue ();
364
364
assertThat (exception ).hasCauseThat ().isInstanceOf (ApiException .class );
365
365
assertThat (exception ).hasCauseThat ().hasMessageThat ().contains ("Unavailable" );
366
366
// Capture the argument passed to futureCall
@@ -401,10 +401,10 @@ void testKnownStatusCode() {
401
401
callInt , callSettings , httpJsonCallSettings , clientContext );
402
402
ApiException exception =
403
403
assertThrows (FailedPreconditionException .class , () -> callable .call (initialRequest ));
404
- assertThat (tracerFactory .getTracerAttempts ().get ()).isEqualTo (1 );
405
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isEqualTo (0 );
406
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isFalse ();
407
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isTrue ();
404
+ assertThat (tracerFactory .getInstance (). getAttemptsStarted ().get ()).isEqualTo (1 );
405
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isEqualTo (0 );
406
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isFalse ();
407
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isTrue ();
408
408
assertThat (exception .getStatusCode ().getTransportCode ())
409
409
.isEqualTo (HTTP_CODE_PRECONDITION_FAILED );
410
410
assertThat (exception ).hasMessageThat ().contains ("precondition failed" );
@@ -429,10 +429,10 @@ void testUnknownStatusCode() {
429
429
UnknownException exception =
430
430
assertThrows (UnknownException .class , () -> callable .call (initialRequest ));
431
431
assertThat (exception ).hasMessageThat ().isEqualTo ("java.lang.RuntimeException: unknown" );
432
- assertThat (tracerFactory .getTracerAttempts ().get ()).isEqualTo (1 );
433
- assertThat (tracerFactory .getTracerAttemptsFailed ().get ()).isEqualTo (0 );
434
- assertThat (tracerFactory .getTracerFailedRetriesExhausted ().get ()).isFalse ();
435
- assertThat (tracerFactory .getTracerOperationFailed ().get ()).isTrue ();
432
+ assertThat (tracerFactory .getInstance (). getAttemptsStarted ().get ()).isEqualTo (1 );
433
+ assertThat (tracerFactory .getInstance (). getAttemptsFailed ().get ()).isEqualTo (0 );
434
+ assertThat (tracerFactory .getInstance (). getRetriesExhausted ().get ()).isFalse ();
435
+ assertThat (tracerFactory .getInstance (). getOperationFailed ().get ()).isTrue ();
436
436
// Capture the argument passed to futureCall
437
437
ArgumentCaptor <Integer > argumentCaptor = ArgumentCaptor .forClass (Integer .class );
438
438
verify (callInt , atLeastOnce ()).futureCall (argumentCaptor .capture (), any (ApiCallContext .class ));
0 commit comments