Search in sources :

Example 1 with GetSamplingTargetsRequest

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());
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) GetSamplingTargetsRequest(com.amazonaws.services.xray.model.GetSamplingTargetsRequest) GetSamplingRulesRequest(com.amazonaws.services.xray.model.GetSamplingRulesRequest) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) Test(org.junit.jupiter.api.Test)

Example 2 with 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\"" + "    }" + " ] " + "}")));
}
Also used : SamplingStatisticsDocument(com.amazonaws.services.xray.model.SamplingStatisticsDocument) GetSamplingTargetsRequest(com.amazonaws.services.xray.model.GetSamplingTargetsRequest) GetSamplingTargetsResult(com.amazonaws.services.xray.model.GetSamplingTargetsResult) Test(org.junit.Test)

Example 3 with GetSamplingTargetsRequest

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());
}
Also used : SamplingStatisticsDocument(com.amazonaws.services.xray.model.SamplingStatisticsDocument) GetSamplingTargetsRequest(com.amazonaws.services.xray.model.GetSamplingTargetsRequest) GetSamplingTargetsResult(com.amazonaws.services.xray.model.GetSamplingTargetsResult)

Example 4 with GetSamplingTargetsRequest

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());
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) GetSamplingTargetsRequest(com.amazonaws.services.xray.model.GetSamplingTargetsRequest) GetSamplingRulesRequest(com.amazonaws.services.xray.model.GetSamplingRulesRequest) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) Segment(com.amazonaws.xray.entities.Segment) Test(org.junit.jupiter.api.Test)

Aggregations

GetSamplingTargetsRequest (com.amazonaws.services.xray.model.GetSamplingTargetsRequest)4 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)2 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)2 GetSamplingRulesRequest (com.amazonaws.services.xray.model.GetSamplingRulesRequest)2 GetSamplingTargetsResult (com.amazonaws.services.xray.model.GetSamplingTargetsResult)2 SamplingStatisticsDocument (com.amazonaws.services.xray.model.SamplingStatisticsDocument)2 Test (org.junit.jupiter.api.Test)2 Segment (com.amazonaws.xray.entities.Segment)1 Test (org.junit.Test)1