use of com.amazonaws.xray.strategy.sampling.SamplingResponse in project aws-xray-sdk-java by aws.
the class AWSXRayRecorderTest method testBeginSegmentWithForcedSampling.
@Test
public void testBeginSegmentWithForcedSampling() {
SamplingResponse response = new SamplingResponse(false, "rule");
when(mockSamplingStrategy.isForcedSamplingSupported()).thenReturn(true);
when(mockSamplingStrategy.shouldTrace(any())).thenReturn(response);
AWSXRay.getGlobalRecorder().setSamplingStrategy(mockSamplingStrategy);
Segment segment = AWSXRay.beginSegmentWithSampling("test");
assertThat(segment.isSampled()).isFalse();
segment.setUser("user");
// Loose way to test that segment is real
assertThat(segment.getUser()).isEqualTo("user");
}
use of com.amazonaws.xray.strategy.sampling.SamplingResponse in project aws-xray-sdk-java by aws.
the class AWSXRayRecorderTest method testBeginSegmentWithSamplingDoesNotSample.
@Test
public void testBeginSegmentWithSamplingDoesNotSample() {
SamplingResponse response = new SamplingResponse(false, "rule");
when(mockSamplingStrategy.shouldTrace(any())).thenReturn(response);
AWSXRay.getGlobalRecorder().setSamplingStrategy(mockSamplingStrategy);
Segment segment = AWSXRay.beginSegmentWithSampling("test");
assertThat(segment.isSampled()).isFalse();
segment.setUser("user");
// Loose way to test that segment is a no-op
assertThat(segment.getUser()).isEmpty();
}
Aggregations