@ApiOperation(value = "Retrieve a list of descriptors for use in populating the canary config ui") @RequestMapping(method = RequestMethod.GET) public List<Map> listMetadata(@RequestParam(required = false) final String metricsAccountName, @RequestParam(required = false) final String filter) throws IOException { String resolvedMetricsAccountName = CredentialsHelper.resolveAccountByNameOrType(metricsAccountName, AccountCredentials.Type.METRICS_STORE, accountCredentialsRepository); MetricsService metricsService = metricsServiceRepository .getOne(resolvedMetricsAccountName) .orElseThrow(() -> new IllegalArgumentException("No metrics service was configured; unable to read from metrics store.")); List<Map> matchingDescriptors = metricsService.getMetadata(resolvedMetricsAccountName, filter); if (StringUtils.isEmpty(filter)) { log.debug("Returned all {} descriptors via account {}.", matchingDescriptors.size(), resolvedMetricsAccountName, filter); } else { log.debug("Matched {} descriptors via account {} using filter '{}'.", matchingDescriptors.size(), resolvedMetricsAccountName, filter); } return metricsService.getMetadata(resolvedMetricsAccountName, filter); } }
public Map processQueryAndReturnMap(String metricsAccountName, String storageAccountName, CanaryConfig canaryConfig, CanaryMetricConfig canaryMetricConfig, int metricIndex, CanaryScope canaryScope, boolean dryRun) throws IOException { if (canaryConfig == null) { canaryConfig = CanaryConfig.builder().metric(canaryMetricConfig).build(); } if (dryRun) { MetricsService metricsService = metricsServiceRepository .getOne(metricsAccountName) .orElseThrow(() -> new IllegalArgumentException("No metrics service was configured; unable to read from metrics store.")); String query = metricsService.buildQuery(metricsAccountName, canaryConfig, canaryMetricConfig, canaryScope); return Collections.singletonMap("query", query); } else { String metricSetListId = executeQuery(metricsAccountName, storageAccountName, canaryConfig, metricIndex, canaryScope); return Collections.singletonMap("metricSetListId", metricSetListId); } }
MetricsService metricsService = metricsServiceRepository .getOne(metricsAccountName) .orElseThrow(() -> new IllegalArgumentException("No metrics service was configured; unable to read from metrics store."));
public Map processQueryAndReturnMap(String metricsAccountName, String storageAccountName, CanaryConfig canaryConfig, CanaryMetricConfig canaryMetricConfig, int metricIndex, CanaryScope canaryScope, boolean dryRun) throws IOException { if (canaryConfig == null) { canaryConfig = CanaryConfig.builder().metric(canaryMetricConfig).build(); } if (dryRun) { MetricsService metricsService = metricsServiceRepository .getOne(metricsAccountName) .orElseThrow(() -> new IllegalArgumentException("No metrics service was configured; unable to read from metrics store.")); String query = metricsService.buildQuery(metricsAccountName, canaryConfig, canaryMetricConfig, canaryScope); return Collections.singletonMap("query", query); } else { String metricSetListId = executeQuery(metricsAccountName, storageAccountName, canaryConfig, metricIndex, canaryScope); return Collections.singletonMap("metricSetListId", metricSetListId); } }
MetricsService metricsService = metricsServiceRepository .getOne(metricsAccountName) .orElseThrow(() -> new IllegalArgumentException("No metrics service was configured; unable to read from metrics store."));