use of com.amazonaws.services.xray.model.GetSamplingTargetsResult in project aws-xray-sdk-java by aws.
the class UnsignedXrayClientTest method getSamplingTargets.
@Test
public void getSamplingTargets() throws Exception {
stubFor(any(anyUrl()).willReturn(aResponse().withStatus(200).withBody(SAMPLING_TARGETS)));
GetSamplingTargetsRequest request = new GetSamplingTargetsRequest().withSamplingStatisticsDocuments(new SamplingStatisticsDocument().withClientID("client-id"));
GetSamplingTargetsResult result = client.getSamplingTargets(request);
GetSamplingTargetsResult expected = OBJECT_MAPPER.readValue(SAMPLING_TARGETS, GetSamplingTargetsResult.class);
assertThat(expected).isEqualTo(result);
verify(postRequestedFor(urlEqualTo("/SamplingTargets")).withHeader("Content-Type", equalTo("application/json")).withRequestBody(equalToJson("{" + " \"SamplingStatisticsDocuments\": [" + " {" + " \"ClientID\": \"client-id\"" + " }" + " ] " + "}")));
}
use of com.amazonaws.services.xray.model.GetSamplingTargetsResult in project aws-xray-sdk-java by aws.
the class TargetPoller method pollManifest.
private void pollManifest() {
List<SamplingStatisticsDocument> statistics = manifest.snapshots(clock.instant());
if (statistics.size() == 0) {
logger.trace("No statistics to report. Not refreshing sampling targets.");
return;
}
logger.debug("Polling sampling targets.");
GetSamplingTargetsRequest req = new GetSamplingTargetsRequest().withSamplingStatisticsDocuments(statistics);
GetSamplingTargetsResult result = client.getSamplingTargets(req);
manifest.putTargets(result.getSamplingTargetDocuments(), clock.instant());
}
Aggregations