@@ -477,41 +477,22 @@ public ClientStreamTracer newClientStreamTracer(StreamInfo info, Metadata header
477477 if (delegateFactory != null ) {
478478 ClientStreamTracer delegateTracer = delegateFactory .newClientStreamTracer (info , headers );
479479 return new ForwardingClientStreamTracer () {
480- private volatile boolean cancelled ;
481-
482480 @ Override
483481 protected ClientStreamTracer delegate () {
484482 return delegateTracer ;
485483 }
486484
487- @ Override
488- public void cancelled (Status status ) {
489- cancelled = true ;
490- delegate ().cancelled (status );
491- }
492-
493485 @ Override
494486 public void streamClosed (Status status ) {
495- if (!cancelled ) {
496- tracker .incrementCallCount (status .isOk ());
497- }
487+ tracker .incrementCallCount (status );
498488 delegate ().streamClosed (status );
499489 }
500490 };
501491 } else {
502492 return new ClientStreamTracer () {
503- private volatile boolean cancelled ;
504-
505- @ Override
506- public void cancelled (Status status ) {
507- cancelled = true ;
508- }
509-
510493 @ Override
511494 public void streamClosed (Status status ) {
512- if (!cancelled ) {
513- tracker .incrementCallCount (status .isOk ());
514- }
495+ tracker .incrementCallCount (status );
515496 }
516497 };
517498 }
@@ -571,13 +552,18 @@ Set<OutlierDetectionSubchannel> getSubchannels() {
571552 return ImmutableSet .copyOf (subchannels );
572553 }
573554
574- void incrementCallCount (boolean success ) {
555+ void incrementCallCount (Status status ) {
575556 // If neither algorithm is configured, no point in incrementing counters.
576557 if (config .successRateEjection == null && config .failurePercentageEjection == null ) {
577558 return ;
578559 }
579560
580- if (success ) {
561+ if (status .getCode () == Status .Code .CANCELLED
562+ || status .getCode () == Status .Code .DEADLINE_EXCEEDED ) {
563+ return ;
564+ }
565+
566+ if (status .isOk ()) {
581567 activeCallCounter .successCount .getAndIncrement ();
582568 } else {
583569 activeCallCounter .failureCount .getAndIncrement ();
0 commit comments