double getErrorRateToDegrade()
  {
    Map<ErrorType, Integer> errorTypeCounts = _callTrackerStats.getErrorTypeCounts();
    Integer connectExceptionCount = errorTypeCounts.getOrDefault(ErrorType.CONNECT_EXCEPTION, 0);
    Integer closedChannelExceptionCount = errorTypeCounts.getOrDefault(ErrorType.CLOSED_CHANNEL_EXCEPTION, 0);
    Integer serverErrorCount = errorTypeCounts.getOrDefault(ErrorType.SERVER_ERROR, 0);
    Integer timeoutExceptionCount = errorTypeCounts.getOrDefault(ErrorType.TIMEOUT_EXCEPTION, 0);
    Integer streamErrorCount = errorTypeCounts.getOrDefault(ErrorType.STREAM_ERROR, 0);

    double validExceptionCount = connectExceptionCount + closedChannelExceptionCount + serverErrorCount
        + timeoutExceptionCount;
    if (_config.getLoadBalanceStreamException())
    {
      validExceptionCount += streamErrorCount;
    }
    return safeDivide(validExceptionCount, _callTrackerStats.getCallCount());
  }
@Test(dataProvider = "loadBalanceStreamExceptionDataProvider")
  public void testGetErrorRateToDegrade(Boolean loadBalancerStreamException)
  {
    Map<ErrorType, Integer> errorTypeCounts = ImmutableMap.of(
        ErrorType.CONNECT_EXCEPTION, 1,
        ErrorType.CLOSED_CHANNEL_EXCEPTION, 1,
        ErrorType.SERVER_ERROR, 1,
        ErrorType.TIMEOUT_EXCEPTION, 1,
        ErrorType.STREAM_ERROR, 1
    );
    DegraderImpl degrader = new DegraderImplTestFixture().getDegraderImpl(loadBalancerStreamException, errorTypeCounts,
        10);
    assertEquals(degrader.getErrorRateToDegrade(), loadBalancerStreamException ? 0.5 : 0.4);
  }