public ResponseCodeClass Classify(string service, ResponseCode code, TimeSpan latency) { var settings = settingsProvider?.Invoke() ?? new ResponseCodeClassifierSettings(); var serviceSettings = GetServiceSettings(settings, service); var serviceCodeClass = TryClassify(code, serviceSettings); if (serviceCodeClass != null) { return(serviceCodeClass.Value); } var codeClass = TryClassify(code, settings); if (codeClass != null) { return(codeClass.Value); } if (code.IsSuccessful() || code.IsRedirection() || code.IsInformational()) { return(ResponseCodeClass.Success); } if (code.IsServerError()) { return(ResponseCodeClass.Error); } if (code == ResponseCode.RequestTimeout) { return(latency >= (serviceSettings?.TimeoutErrorClassificationThreshold ?? settings.TimeoutErrorClassificationThreshold) ? ResponseCodeClass.Error : ResponseCodeClass.Warning); } if (code.IsNetworkError()) { return(ResponseCodeClass.Error); } if (code == ResponseCode.Unknown || code == ResponseCode.UnknownFailure) { return(ResponseCodeClass.Error); } return(ResponseCodeClass.Warning); }