use of org.cloudfoundry.promregator.fetcher.MetricsFetcher in project promregator by promregator.
the class AbstractMetricsEndpoint method handleRequest.
public String handleRequest() {
Instant start = Instant.now();
this.up.clear();
List<Instance> instanceList = this.appInstanceScanner.determineInstancesFromTargets(this.promregatorConfiguration.getTargets());
instanceList = this.filterInstanceList(instanceList);
List<MetricsFetcher> callablesPrep = this.createMetricsFetchers(instanceList);
LinkedList<Future<HashMap<String, MetricFamilySamples>>> futures = this.startMetricsFetchers(callablesPrep);
MergableMetricFamilySamples mmfs = waitForMetricsFetchers(futures);
Instant stop = Instant.now();
Duration duration = Duration.between(start, stop);
this.scrape_duration.set(duration.toMillis() / 1000.0);
if (this.isIncludeGlobalMetrics()) {
// also add our own (global) metrics
mmfs.merge(this.gmfspr.determineEnumerationOfMetricFamilySamples(this.collectorRegistry));
}
// add also our own request-specific metrics
mmfs.merge(this.gmfspr.determineEnumerationOfMetricFamilySamples(this.requestRegistry));
return mmfs.toType004String();
}
use of org.cloudfoundry.promregator.fetcher.MetricsFetcher in project promregator by promregator.
the class AbstractMetricsEndpoint method createMetricsFetchers.
protected List<MetricsFetcher> createMetricsFetchers(List<Instance> instanceList) {
List<MetricsFetcher> callablesList = new LinkedList<>();
for (Instance instance : instanceList) {
log.info(String.format("Instance %s", instance.getInstanceId()));
Target target = instance.getTarget();
String orgName = target.getOrgName();
String spaceName = target.getSpaceName();
String appName = target.getApplicationName();
String accessURL = instance.getAccessUrl();
if (accessURL == null) {
log.warn(String.format("Unable to retrieve hostname for %s/%s/%s; skipping", orgName, spaceName, appName));
continue;
}
AbstractMetricFamilySamplesEnricher mfse = new CFMetricFamilySamplesEnricher(orgName, spaceName, appName, instance.getInstanceId());
MetricsFetcherMetrics mfm = new MetricsFetcherMetrics(mfse, up);
MetricsFetcher mf = null;
if (this.proxyHost != null && this.proxyPort != 0) {
mf = new CFMetricsFetcher(accessURL, instance.getInstanceId(), this.ae, mfse, this.proxyHost, this.proxyPort, mfm);
} else {
mf = new CFMetricsFetcher(accessURL, instance.getInstanceId(), this.ae, mfse, mfm);
}
callablesList.add(mf);
}
return callablesList;
}
use of org.cloudfoundry.promregator.fetcher.MetricsFetcher in project promregator by promregator.
the class TestableMetricsEndpoint method createMetricsFetchers.
@Override
protected List<MetricsFetcher> createMetricsFetchers(List<Instance> instanceList) {
List<MetricsFetcher> list = new LinkedList<>();
for (Instance instance : instanceList) {
MockedMetricsFetcher mf = new MockedMetricsFetcher(instance);
list.add(mf);
}
return list;
}
use of org.cloudfoundry.promregator.fetcher.MetricsFetcher in project promregator by promregator.
the class AbstractMetricsEndpoint method startMetricsFetchers.
private LinkedList<Future<HashMap<String, MetricFamilySamples>>> startMetricsFetchers(List<MetricsFetcher> callablesPrep) {
LinkedList<Future<HashMap<String, MetricFamilySamples>>> futures = new LinkedList<>();
for (MetricsFetcher mf : callablesPrep) {
Future<HashMap<String, MetricFamilySamples>> future = this.metricsFetcherPool.submit(mf);
futures.add(future);
}
return futures;
}
Aggregations