Java Code Examples for com.amazonaws.xray.AWSXRay#setGlobalRecorder()
The following examples show how to use
com.amazonaws.xray.AWSXRay#setGlobalRecorder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomSegmentContextTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@Before public void setupAWSXRay() { Emitter blankEmitter = Mockito.mock(Emitter.class); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject()); Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject()); LocalizedSamplingStrategy defaultSamplingStrategy = new LocalizedSamplingStrategy(); SegmentContextResolverChain chain = new SegmentContextResolverChain(); chain.addResolver(new GlobalMapSegmentContextResolver()); AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard() .withEmitter(blankEmitter) .withSegmentContextResolverChain(chain) .withSamplingStrategy(defaultSamplingStrategy) .build()); AWSXRay.clearTraceEntity(); }
Example 2
Source File: TracingHandlerTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@Test public void testRaceConditionOnRecorderInitialization() { AWSXRay.setGlobalRecorder(null); // TracingHandler will not have the initialized recorder AWSLambda lambda = AWSLambdaClientBuilder .standard() .withRequestHandlers(new TracingHandler()) .withRegion(Regions.US_EAST_1) .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake"))) .build(); mockHttpClient(lambda, "null"); // Now init the global recorder AWSXRayRecorder recorder = AWSXRayRecorderBuilder.defaultRecorder(); recorder.setContextMissingStrategy(new LogErrorContextMissingStrategy()); AWSXRay.setGlobalRecorder(recorder); // Test logic InvokeRequest request = new InvokeRequest(); request.setFunctionName("testFunctionName"); lambda.invoke(request); }
Example 3
Source File: SLF4JSegmentListenerTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setupAWSXRay() { Emitter blankEmitter = Mockito.mock(Emitter.class); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.any()); Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.any()); SLF4JSegmentListener segmentListener = new SLF4JSegmentListener(); AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withEmitter(blankEmitter).withSegmentListener(segmentListener).build()); AWSXRay.clearTraceEntity(); MDC.clear(); }
Example 4
Source File: TracingHandlerTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setupAWSXRay() { Emitter blankEmitter = Mockito.mock(Emitter.class); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject()); Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject()); AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withEmitter(blankEmitter).build()); AWSXRay.clearTraceEntity(); }
Example 5
Source File: SegmentContextExecutorsTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setUp() { when(recorder.getTraceEntity()).thenAnswer(invocation -> ThreadLocalStorage.get()); when(recorder.getCurrentSegmentOptional()).thenAnswer(invocation -> Optional.of(ThreadLocalStorage.get())); doAnswer(invocation -> { ThreadLocalStorage.set(invocation.getArgument(0)); return null; }).when(recorder).setTraceEntity(any()); recorder.setTraceEntity(current); AWSXRay.setGlobalRecorder(recorder); }
Example 6
Source File: LambdaSegmentContextTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setupAWSXRay() { Emitter blankEmitter = Mockito.mock(Emitter.class); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject()); Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject()); AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard() .withEmitter(blankEmitter) .withSamplingStrategy(new LocalizedSamplingStrategy()) .build()); AWSXRay.clearTraceEntity(); }
Example 7
Source File: SegmentListenerTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setupAWSXRay() { Emitter blankEmitter = Mockito.mock(Emitter.class); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.any()); Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.any()); CustomSegmentListener segmentListener = new CustomSegmentListener(); AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard() .withEmitter(blankEmitter) .withSegmentListener(segmentListener) .build()); AWSXRay.clearTraceEntity(); }
Example 8
Source File: DefaultStreamingStrategyTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setupAWSXRay() { Emitter blankEmitter = Mockito.mock(Emitter.class); LocalizedSamplingStrategy defaultSamplingStrategy = new LocalizedSamplingStrategy(); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject()); Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject()); AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard() .withEmitter(blankEmitter) .withSamplingStrategy(defaultSamplingStrategy) .build()); AWSXRay.clearTraceEntity(); }
Example 9
Source File: AWSXRayServletFilterTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Test public void testServletLazilyLoadsRecorder() throws IOException, ServletException { AWSXRayServletFilter servletFilter = new AWSXRayServletFilter("test"); AsyncContext asyncContext = Mockito.mock(AsyncContext.class); AWSXRayRecorder customRecorder = Mockito.spy(getMockRecorder()); AWSXRay.setGlobalRecorder(customRecorder); HttpServletRequest request = Mockito.mock(HttpServletRequest.class); Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("test_url")); Mockito.when(request.getMethod()).thenReturn("TEST_METHOD"); Mockito.when(request.isAsyncStarted()).thenReturn(true); Mockito.when(request.getAsyncContext()).thenReturn(asyncContext); HttpServletResponse response = Mockito.mock(HttpServletResponse.class); FilterChain chain = mockChain(request, response); AsyncEvent event = Mockito.mock(AsyncEvent.class); Mockito.when(event.getSuppliedRequest()).thenReturn(request); Mockito.when(event.getSuppliedResponse()).thenReturn(response); servletFilter.doFilter(request, response, chain); Assert.assertNull(AWSXRay.getTraceEntity()); AWSXRayServletAsyncListener listener = (AWSXRayServletAsyncListener) Whitebox.getInternalState(servletFilter, "listener"); listener.onComplete(event); Mockito.verify(customRecorder.getEmitter(), Mockito.times(1)).sendSegment(Mockito.any()); }
Example 10
Source File: Log4JSegmentListenerTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setupAWSXRay() { Emitter blankEmitter = Mockito.mock(Emitter.class); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.any()); Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.any()); Log4JSegmentListener segmentListener = new Log4JSegmentListener(); AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard() .withEmitter(blankEmitter) .withSegmentListener(segmentListener) .build()); AWSXRay.clearTraceEntity(); ThreadContext.clearAll(); }
Example 11
Source File: TracingInterceptorTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setup() { Emitter blankEmitter = Mockito.mock(Emitter.class); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject()); AWSXRay.setGlobalRecorder( AWSXRayRecorderBuilder.standard() .withEmitter(blankEmitter) .build() ); AWSXRay.clearTraceEntity(); AWSXRay.beginSegment("test"); }
Example 12
Source File: BaseAbstractXRayInterceptorTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setup() { AWSXRay.setGlobalRecorder(mockRecorder); when(mockPjp.getArgs()).thenReturn(new Object[] {}); when(mockPjp.getSignature()).thenReturn(mockSignature); when(mockSignature.getName()).thenReturn("testSpringName"); }
Example 13
Source File: TracedResponseHandlerTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setupAWSXRay() { Emitter blankEmitter = Mockito.mock(Emitter.class); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject()); Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject()); AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withEmitter(blankEmitter).build()); AWSXRay.clearTraceEntity(); }
Example 14
Source File: HttpClientBuilderTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Before public void setupAWSXRay() { // Prevent accidental publish to Daemon Emitter blankEmitter = Mockito.mock(Emitter.class); Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject()); Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject()); AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withEmitter(blankEmitter).build()); AWSXRay.clearTraceEntity(); }
Example 15
Source File: ApplicationModule.java From realworld-serverless-application with Apache License 2.0 | 5 votes |
@Override protected void configure() { // Disable AWS x-ray in integration tests. // See doc: https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-configuration.html#xray-sdk-java-configuration-sysprops AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withContextMissingStrategy(new LogErrorContextMissingStrategy()).build()); bind(ScenarioScope.class).toInstance(new SequentialScenarioScope()); }
Example 16
Source File: ApplicationModule.java From realworld-serverless-application with Apache License 2.0 | 5 votes |
@Override protected void configure() { // Disable AWS x-ray in integration tests. // See doc: https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-configuration.html#xray-sdk-java-configuration-sysprops AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withContextMissingStrategy(new LogErrorContextMissingStrategy()).build()); bind(ScenarioScope.class).toInstance(new SequentialScenarioScope()); }
Example 17
Source File: InvokeTest.java From aws-doc-sdk-examples with Apache License 2.0 | 4 votes |
public InvokeTest() { AWSXRayRecorderBuilder builder = AWSXRayRecorderBuilder.standard(); builder.withSamplingStrategy(new NoSamplingStrategy()); AWSXRay.setGlobalRecorder(builder.build()); }
Example 18
Source File: AWSXRayServletFilterTest.java From aws-xray-sdk-java with Apache License 2.0 | 4 votes |
@Before public void setupAWSXRay() { AWSXRay.setGlobalRecorder(getMockRecorder()); AWSXRay.clearTraceEntity(); }
Example 19
Source File: AWSXRayServletContext.java From deployment-examples with MIT License | 4 votes |
public void contextInitialized(ServletContextEvent servletContextEvent) { // Initialize AWS XRay Recorder before any filters or servlets are created AWSXRayRecorderBuilder builder = AWSXRayRecorderBuilder.standard().withPlugin(new ElasticBeanstalkPlugin()); AWSXRay.setGlobalRecorder(builder.build()); }