@Test public void updateMetricDescriptorsCache_ignoresNonPrometheusAccounts() { when(accountCredentialRepo.getAllOf(AccountCredentials.Type.METRICS_STORE)) .thenReturn(Collections.singleton(new TestAccountCredentials())); cache.updateMetricDescriptorsCache(); verify(accountCredentialRepo).getAllOf(AccountCredentials.Type.METRICS_STORE); }
@Scheduled(fixedDelayString = "#{@prometheusConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() { Set<AccountCredentials> accountCredentialsSet = accountCredentialsRepository.getAllOf(AccountCredentials.Type.METRICS_STORE); Map<String, List<PrometheusMetricDescriptor>> updatedCache = accountCredentialsSet.stream() .filter(credentials -> credentials instanceof PrometheusNamedAccountCredentials) .map(credentials -> (PrometheusNamedAccountCredentials) credentials) .map(this::listMetricDescriptors) .filter(this::isSuccessful) .filter(this::hasData) .collect( Collectors.toMap( AccountResponse::getMetricsAccountName, this::toPrometheusMetricDescriptors)); this.cache = updatedCache; }
PrometheusMetricDescriptorsCache { @Scheduled(fixedDelayString = "#{@prometheusConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() { Set<AccountCredentials> accountCredentialsSet = accountCredentialsRepository.getAllOf(AccountCredentials.Type.METRICS_STORE); Map<String, List<PrometheusMetricDescriptor>> updatedCache = accountCredentialsSet.stream() .filter(credentials -> credentials instanceof PrometheusNamedAccountCredentials) .map(credentials -> (PrometheusNamedAccountCredentials) credentials) .map(this::listMetricDescriptors) .filter(this::isSuccessful) .filter(this::hasData) .collect( Collectors.toMap( AccountResponse::getMetricsAccountName, this::toPrometheusMetricDescriptors)); this.cache = updatedCache; } }
PrometheusMetricDescriptorsCache { @Scheduled(fixedDelayString = "#{@prometheusConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() { Set<AccountCredentials> accountCredentialsSet = accountCredentialsRepository.getAllOf(AccountCredentials.Type.METRICS_STORE); Map<String, List<PrometheusMetricDescriptor>> updatedCache = accountCredentialsSet.stream() .filter(credentials -> credentials instanceof PrometheusNamedAccountCredentials) .map(credentials -> (PrometheusNamedAccountCredentials) credentials) .map(this::listMetricDescriptors) .filter(this::isSuccessful) .filter(this::hasData) .collect( Collectors.toMap( AccountResponse::getMetricsAccountName, this::toPrometheusMetricDescriptors)); this.cache = updatedCache; } PrometheusMetricDescriptorsCache(
      AccountCredentialsRepository accountCredentialsRepository); }
PrometheusMetricDescriptorsCache { @Scheduled(fixedDelayString = "#{@prometheusConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() { Set<AccountCredentials> accountCredentialsSet = accountCredentialsRepository.getAllOf(AccountCredentials.Type.METRICS_STORE); Map<String, List<PrometheusMetricDescriptor>> updatedCache = accountCredentialsSet.stream() .filter(credentials -> credentials instanceof PrometheusNamedAccountCredentials) .map(credentials -> (PrometheusNamedAccountCredentials) credentials) .map(this::listMetricDescriptors) .filter(this::isSuccessful) .filter(this::hasData) .collect( Collectors.toMap( AccountResponse::getMetricsAccountName, this::toPrometheusMetricDescriptors)); this.cache = updatedCache; } PrometheusMetricDescriptorsCache(
      AccountCredentialsRepository accountCredentialsRepository); List<Map> getMetadata(String metricsAccountName, String filter); @Scheduled(fixedDelayString = "#{@prometheusConfigurationProperties.metadataCachingIntervalMS}") void updateMetricDescriptorsCache(); }
PrometheusMetricDescriptorsCache { @Scheduled(fixedDelayString = "#{@prometheusConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() { Set<AccountCredentials> accountCredentialsSet = accountCredentialsRepository.getAllOf(AccountCredentials.Type.METRICS_STORE); Map<String, List<PrometheusMetricDescriptor>> updatedCache = accountCredentialsSet.stream() .filter(credentials -> credentials instanceof PrometheusNamedAccountCredentials) .map(credentials -> (PrometheusNamedAccountCredentials) credentials) .map(this::listMetricDescriptors) .filter(this::isSuccessful) .filter(this::hasData) .collect( Collectors.toMap( AccountResponse::getMetricsAccountName, this::toPrometheusMetricDescriptors)); this.cache = updatedCache; } PrometheusMetricDescriptorsCache(
      AccountCredentialsRepository accountCredentialsRepository); List<Map> getMetadata(String metricsAccountName, String filter); @Scheduled(fixedDelayString = "#{@prometheusConfigurationProperties.metadataCachingIntervalMS}") void updateMetricDescriptorsCache();  }