Skip to content

Commit 701ab4e

Browse files
luramarchanjogeoand
authored andcommitted
Actuator endpoint skipped by default (#99)
1 parent 3a35c7d commit 701ab4e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

opentracing-spring-web-starter/src/main/java/io/opentracing/contrib/spring/web/starter/WebTracingProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class WebTracingProperties {
2727
public static final String CONFIGURATION_PREFIX = "opentracing.spring.web";
2828

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

3333
private boolean enabled = true;

opentracing-spring-web-starter/src/test/java/io/opentracing/contrib/spring/web/starter/ServerTracingAutoConfigurationDefaultsTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class ServerTracingAutoConfigurationDefaultsTest extends AutoConfiguratio
5252

5353
private static CountDownLatch infoCountDownLatch = new CountDownLatch(1);
5454

55+
private static CountDownLatch actuatorInfoCountDownLatch = new CountDownLatch(1);
56+
5557
@RestController
5658
@Configuration
5759
@EnableAutoConfiguration
@@ -73,6 +75,11 @@ public void nestedHello() {
7375
public void info() {
7476
infoCountDownLatch.countDown();
7577
}
78+
79+
@RequestMapping("/actuator/info")
80+
public void actuatorInfo() {
81+
actuatorInfoCountDownLatch.countDown();
82+
}
7683
}
7784

7885
@Autowired
@@ -106,7 +113,7 @@ public void testNestedRequestIsTraced() {
106113

107114
// Test that /info is excluded due to the default skipPattern
108115
@Test
109-
public void testExcluded() throws InterruptedException {
116+
public void testInfoExcluded() throws InterruptedException {
110117
testRestTemplate.getForEntity("/info", String.class);
111118
infoCountDownLatch.await();
112119

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

125+
// Test that /actuator/info is excluded due to the default skipPattern
126+
@Test
127+
public void testActuatorExcluded() throws InterruptedException {
128+
testRestTemplate.getForEntity("/actuator/info", String.class);
129+
actuatorInfoCountDownLatch.await();
130+
131+
assertThat(mockTracer.finishedSpans()).hasSize(0);
132+
assertThat(Mockito.mockingDetails(mockDecorator1).getInvocations()).hasSize(0);
133+
assertThat(Mockito.mockingDetails(mockDecorator2).getInvocations()).hasSize(0);
134+
}
135+
118136
public Callable<Integer> reportedSpansSize() {
119137
return () -> mockTracer.finishedSpans().size();
120138
}

0 commit comments

Comments
 (0)