class AnomalyRepositoryImpl implements AnomalyRepository {

    @Override
    public List<OutlierDetectorResult> getAnomalies(AnomalyRequest request) {
        val metricDef = MetricUtil.metricDefinition();
        val detector = buildDetector(request);

        val anomalyResults = new ArrayList<OutlierDetectorResult>();
        metricSources.forEach(metricSource -> {
            val results = metricSource.getMetricData(request.getMetricTags());
            for (val result : results) {
                val metricData = MetricUtil.metricData(metricDef, result.getDataPoint(), result.getEpochSecond());
                val anomalyResult = (OutlierDetectorResult) detector.detect(metricData);
                anomalyResults.add(anomalyResult);
            }
        });
        return anomalyResults;
    }

}