fix: wrap `ExperimentService` in a try (#546)

This commit is contained in:
Justin Perez 2023-05-01 10:15:19 -07:00 коммит произвёл GitHub
Родитель f9597482b8
Коммит 804182a508
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 27 добавлений и 21 удалений

Просмотреть файл

@ -37,30 +37,37 @@ public class ExperimentService : IExperimentService
/// <inheritdoc />
public void RecordDetectorRun(IComponentDetector detector, IEnumerable<DetectedComponent> components)
{
this.FilterExperiments(detector, components.Count());
foreach (var (config, experimentResults) in this.experiments)
try
{
if (config.IsInControlGroup(detector))
{
experimentResults.AddComponentsToControlGroup(components);
this.logger.LogDebug(
"Adding {Count} Components from {Id} to Control Group for {Experiment}",
components.Count(),
detector.Id,
config.Name);
}
this.FilterExperiments(detector, components.Count());
if (config.IsInExperimentGroup(detector))
foreach (var (config, experimentResults) in this.experiments)
{
experimentResults.AddComponentsToExperimentalGroup(components);
this.logger.LogDebug(
"Adding {Count} Components from {Id} to Experiment Group for {Experiment}",
components.Count(),
detector.Id,
config.Name);
if (config.IsInControlGroup(detector))
{
experimentResults.AddComponentsToControlGroup(components);
this.logger.LogDebug(
"Adding {Count} Components from {Id} to Control Group for {Experiment}",
components.Count(),
detector.Id,
config.Name);
}
if (config.IsInExperimentGroup(detector))
{
experimentResults.AddComponentsToExperimentalGroup(components);
this.logger.LogDebug(
"Adding {Count} Components from {Id} to Experiment Group for {Experiment}",
components.Count(),
detector.Id,
config.Name);
}
}
}
catch (Exception e)
{
this.logger.LogWarning(e, "Failed to record detector run");
}
}
private void FilterExperiments(IComponentDetector detector, int count)
@ -98,10 +105,9 @@ public class ExperimentService : IExperimentService
continue;
}
var diff = new ExperimentDiff(controlComponents, experimentComponents);
try
{
var diff = new ExperimentDiff(controlComponents, experimentComponents);
var tasks = this.experimentProcessors.Select(x => x.ProcessExperimentAsync(config, diff));
await Task.WhenAll(tasks);
}