protected override TreatmentResult GetTreatmentForFeature(Key key, string feature, Dictionary <string, object> attributes = null) { try { var split = splitCache.GetSplit(feature); if (split == null) { _log.Warn(string.Format("Unknown or invalid feature: {0}", feature)); return(new TreatmentResult(LabelSplitNotFound, Control, null)); } var parsedSplit = splitParser.Parse((Split)split); var treatmentResult = GetTreatment(key, parsedSplit, attributes, this); treatmentResult.Config = parsedSplit.configurations == null || !parsedSplit.configurations.Any() ? null : parsedSplit.configurations[treatmentResult.Treatment]; return(treatmentResult); } catch (Exception e) { _log.Error(string.Format("Exception caught getting treatment for feature: {0}", feature), e); return(new TreatmentResult(LabelException, Control, null)); } }
protected override string GetTreatmentForFeature(Key key, string feature, Dictionary <string, object> attributes = null, bool logMetricsAndImpressions = true) { long start = CurrentTimeHelper.CurrentTimeMillis(); var clock = new Stopwatch(); clock.Start(); try { var split = splitCache.GetSplit(feature); if (split == null) { if (logMetricsAndImpressions) { //if split definition was not found, impression label = "rules not found" RecordStats(key, feature, null, LabelSplitNotFound, start, Control, SdkGetTreatment, clock); } Log.Warn(String.Format("Unknown or invalid feature: {0}", feature)); return(Control); } ParsedSplit parsedSplit = splitParser.Parse((Split)split); var treatment = GetTreatment(key, parsedSplit, attributes, start, clock, this, logMetricsAndImpressions); return(treatment); } catch (Exception e) { if (logMetricsAndImpressions) { //if there was an exception, impression label = "exception" RecordStats(key, feature, null, LabelException, start, Control, SdkGetTreatment, clock); } Log.Error(String.Format("Exception caught getting treatment for feature: {0}", feature), e); return(Control); } }