Search in sources :

Example 1 with GetSamplingRulesRequest

use of com.amazonaws.services.xray.model.GetSamplingRulesRequest 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 GetSamplingRulesRequest

use of com.amazonaws.services.xray.model.GetSamplingRulesRequest in project aws-xray-sdk-java by aws.

the class UnsignedXrayClientTest method getSamplingRules.

@Test
public void getSamplingRules() throws Exception {
    stubFor(any(anyUrl()).willReturn(aResponse().withStatus(200).withBody(SAMPLING_RULES)));
    GetSamplingRulesResult result = client.getSamplingRules(new GetSamplingRulesRequest());
    GetSamplingRulesResult expected = OBJECT_MAPPER.readValue(SAMPLING_RULES, GetSamplingRulesResult.class);
    assertThat(expected).isEqualTo(result);
    verify(postRequestedFor(urlEqualTo("/GetSamplingRules")).withHeader("Content-Type", equalTo("application/json")).withRequestBody(equalToJson("{}")));
}
Also used : GetSamplingRulesResult(com.amazonaws.services.xray.model.GetSamplingRulesResult) GetSamplingRulesRequest(com.amazonaws.services.xray.model.GetSamplingRulesRequest) Test(org.junit.Test)

Example 3 with GetSamplingRulesRequest

use of com.amazonaws.services.xray.model.GetSamplingRulesRequest in project aws-xray-sdk-java by aws.

the class RulePoller method pollRule.

private void pollRule() {
    Instant now = clock.instant();
    logger.info("Polling sampling rules.");
    GetSamplingRulesRequest req = new GetSamplingRulesRequest();
    GetSamplingRulesResult records = client.getSamplingRules(req);
    List<SamplingRule> rules = records.getSamplingRuleRecords().stream().map(SamplingRuleRecord::getSamplingRule).filter(CentralizedRule::isValid).collect(Collectors.toList());
    manifest.putRules(rules, now);
}
Also used : SamplingRuleRecord(com.amazonaws.services.xray.model.SamplingRuleRecord) GetSamplingRulesResult(com.amazonaws.services.xray.model.GetSamplingRulesResult) Instant(java.time.Instant) GetSamplingRulesRequest(com.amazonaws.services.xray.model.GetSamplingRulesRequest) SamplingRule(com.amazonaws.services.xray.model.SamplingRule)

Example 4 with GetSamplingRulesRequest

use of com.amazonaws.services.xray.model.GetSamplingRulesRequest 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

GetSamplingRulesRequest (com.amazonaws.services.xray.model.GetSamplingRulesRequest)4 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)2 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)2 GetSamplingRulesResult (com.amazonaws.services.xray.model.GetSamplingRulesResult)2 GetSamplingTargetsRequest (com.amazonaws.services.xray.model.GetSamplingTargetsRequest)2 Test (org.junit.jupiter.api.Test)2 SamplingRule (com.amazonaws.services.xray.model.SamplingRule)1 SamplingRuleRecord (com.amazonaws.services.xray.model.SamplingRuleRecord)1 Segment (com.amazonaws.xray.entities.Segment)1 Instant (java.time.Instant)1 Test (org.junit.Test)1