Skip to content

Commit

Permalink
Actuator endpoint skipped by default (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
luramarchanjo authored and geoand committed Apr 12, 2019
1 parent 3a35c7d commit 701ab4e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class WebTracingProperties {
public static final String CONFIGURATION_PREFIX = "opentracing.spring.web";

public static final Pattern DEFAULT_SKIP_PATTERN = Pattern.compile(
"/api-docs.*|/autoconfig|/configprops|/dump|/health|/info|/metrics.*|" +
"/api-docs.*|/autoconfig|/configprops|/dump|/health|/info|/metrics.*|/actuator.*|" +
"/mappings|/swagger.*|.*\\.png|.*\\.css|.*\\.js|.*\\.html|/favicon.ico|/hystrix.stream");

private boolean enabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class ServerTracingAutoConfigurationDefaultsTest extends AutoConfiguratio

private static CountDownLatch infoCountDownLatch = new CountDownLatch(1);

private static CountDownLatch actuatorInfoCountDownLatch = new CountDownLatch(1);

@RestController
@Configuration
@EnableAutoConfiguration
Expand All @@ -73,6 +75,11 @@ public void nestedHello() {
public void info() {
infoCountDownLatch.countDown();
}

@RequestMapping("/actuator/info")
public void actuatorInfo() {
actuatorInfoCountDownLatch.countDown();
}
}

@Autowired
Expand Down Expand Up @@ -106,7 +113,7 @@ public void testNestedRequestIsTraced() {

// Test that /info is excluded due to the default skipPattern
@Test
public void testExcluded() throws InterruptedException {
public void testInfoExcluded() throws InterruptedException {
testRestTemplate.getForEntity("/info", String.class);
infoCountDownLatch.await();

Expand All @@ -115,6 +122,17 @@ public void testExcluded() throws InterruptedException {
assertThat(Mockito.mockingDetails(mockDecorator2).getInvocations()).hasSize(0);
}

// Test that /actuator/info is excluded due to the default skipPattern
@Test
public void testActuatorExcluded() throws InterruptedException {
testRestTemplate.getForEntity("/actuator/info", String.class);
actuatorInfoCountDownLatch.await();

assertThat(mockTracer.finishedSpans()).hasSize(0);
assertThat(Mockito.mockingDetails(mockDecorator1).getInvocations()).hasSize(0);
assertThat(Mockito.mockingDetails(mockDecorator2).getInvocations()).hasSize(0);
}

public Callable<Integer> reportedSpansSize() {
return () -> mockTracer.finishedSpans().size();
}
Expand Down

0 comments on commit 701ab4e

Please sign in to comment.