private SpanContextInformation invokeEventListener() { return invokeEventListener(true); }
@Test public void testProfileThisExecutionDeactive() throws Exception { doReturn(0d).when(tracingPlugin).getProfilerRateLimitPerMinute(); final SpanContextInformation spanContext = invokeEventListener(); assertThat(spanContext.getCallTree()).isNull(); }
@Test public void testDontActivateProfilerWhenSpanIsNotSampled() throws Exception { doReturn(1000000d).when(tracingPlugin).getProfilerRateLimitPerMinute(); final SpanContextInformation spanContext = invokeEventListener(false); assertThat(spanContext.getCallTree()).isNull(); }
@Test public void testRateLimiting() throws Exception { when(tracingPlugin.getProfilerRateLimitPerMinute()).thenReturn(1d); final SpanContextInformation spanContext1 = invokeEventListener(); assertNotNull(spanContext1.getCallTree()); final SpanContextInformation spanContext2 = invokeEventListener(); assertNotNull(spanContext2.getCallTree()); }
@Test public void testExcludeCallTreeTags() throws Exception { doReturn(1000000d).when(tracingPlugin).getProfilerRateLimitPerMinute(); when(tracingPlugin.getExcludedTags()).thenReturn(Arrays.asList(SpanUtils.CALL_TREE_JSON, SpanUtils.CALL_TREE_ASCII)); final SpanContextInformation spanContext = invokeEventListener(); assertThat(spanContext.getCallTree()).isNotNull(); assertThat(span.getStringTag(SpanUtils.CALL_TREE_JSON)).isNull(); assertThat(span.getStringTag(SpanUtils.CALL_TREE_ASCII)).isNull(); }
@Test public void testProfileThisExecutionAlwaysActive() throws Exception { doReturn(1000000d).when(tracingPlugin).getProfilerRateLimitPerMinute(); final SpanContextInformation spanContext = invokeEventListener(); assertThat(spanContext.getCallTree()).isNotNull(); assertThat(span.getStringTag(SpanUtils.CALL_TREE_JSON)).isNotNull(); assertThat(span.getStringTag(SpanUtils.CALL_TREE_ASCII)).isNotNull(); }