use of org.cloudfoundry.promregator.scanner.Instance in project promregator by promregator.
the class SingleTargetMetricsEndpointTest method testfilterInstanceListNegative.
@Test(expected = HttpClientErrorException.class)
public void testfilterInstanceListNegative() {
// NB: required to set up the test properly
this.getMetrics("59ff5929-b593-4d90-a3b3-95f4883a8553", "1");
List<Instance> instanceList = new LinkedList<>();
Target t;
t = new Target();
t.setOrgName("unittestorg");
t.setSpaceName("unittestspace");
t.setApplicationName("unittestapp");
t.setPath("/metricsPath");
t.setProtocol("https");
instanceList.add(new Instance(t, "129856d2-c53b-4971-b100-4ce371b78070:41", "https://someurl"));
instanceList.add(new Instance(t, "229856d2-c53b-4971-b100-4ce371b78070:42", "https://someurl"));
Instance i;
i = new Instance(t, "129856d2-c53b-4971-b100-4ce371b78070:42", "https://someurl");
instanceList.add(i);
List<Instance> result = this.filterInstanceList(instanceList);
}
use of org.cloudfoundry.promregator.scanner.Instance 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.scanner.Instance in project promregator by promregator.
the class DiscoveryEndpoint method getDiscovery.
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public DiscoveryResponse[] getDiscovery(HttpServletRequest request) {
List<Instance> instances = this.appInstanceScanner.determineInstancesFromTargets(this.promregatorConfiguration.getTargets());
String localHostname = this.myHostname != null ? this.myHostname : request.getLocalName();
int localPort = this.myPort != 0 ? this.myPort : request.getLocalPort();
final String[] targets = { String.format("%s:%d", localHostname, localPort) };
log.info(String.format("Using scraping target %s in discovery response", targets[0]));
List<DiscoveryResponse> result = new LinkedList<>();
for (Instance instance : instances) {
String path = String.format(SingleTargetMetricsEndpoint.ENDPOINT_PATH + "/%s/%s", instance.getApplicationId(), instance.getInstanceNumber());
DiscoveryLabel dl = new DiscoveryLabel(path, instance);
DiscoveryResponse dr = new DiscoveryResponse(targets, dl);
result.add(dr);
}
// finally, also add our own metrics endpoint
DiscoveryLabel dl = new DiscoveryLabel(PromregatorMetricsEndpoint.ENDPOINT_PATH);
result.add(new DiscoveryResponse(targets, dl));
log.info(String.format("Returing discovery document with %d targets", result.size()));
return result.toArray(new DiscoveryResponse[0]);
}
Aggregations