use of com.amazonaws.services.xray.model.GetSamplingTargetsRequest in project aws-xray-sdk-java by aws.
the class TracingHandlerTest method testShouldNotThrowContextMissingOnXRaySampling.
@Test
void testShouldNotThrowContextMissingOnXRaySampling() {
com.amazonaws.services.xray.AWSXRay xray = AWSXRayClientBuilder.standard().withRequestHandlers(new TracingHandler()).withRegion(Regions.US_EAST_1).withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake"))).build();
mockHttpClient(xray, null);
xray.getSamplingRules(new GetSamplingRulesRequest());
xray.getSamplingTargets(new GetSamplingTargetsRequest());
}
use of com.amazonaws.services.xray.model.GetSamplingTargetsRequest 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.GetSamplingTargetsRequest 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());
}
use of com.amazonaws.services.xray.model.GetSamplingTargetsRequest in project aws-xray-sdk-java by aws.
the class TracingHandlerTest method testShouldNotTraceXRaySamplingOperations.
@Test
void testShouldNotTraceXRaySamplingOperations() {
com.amazonaws.services.xray.AWSXRay xray = AWSXRayClientBuilder.standard().withRequestHandlers(new TracingHandler()).withRegion(Regions.US_EAST_1).withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake"))).build();
mockHttpClient(xray, null);
Segment segment = AWSXRay.beginSegment("test");
xray.getSamplingRules(new GetSamplingRulesRequest());
Assertions.assertEquals(0, segment.getSubsegments().size());
xray.getSamplingTargets(new GetSamplingTargetsRequest());
Assertions.assertEquals(0, segment.getSubsegments().size());
}
Aggregations