Web skip patterns don't consider server.servlet.context-path
See original GitHub issueThe SkipPatternProvider
made in auto-configuration considers when management.server.servlet.context-path
is set, but it does not consider when just server.sevlet.context-path
is set.
The following test demonstrates this issue and will fail with current snapshots:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = DemoSleuthSkipApplicationTests.Config.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"spring.sleuth.sampler.probability:1",
"management.endpoints.web.exposure.include:*",
"server.servlet.context-path:/context-path"})
public class DemoSleuthSkipApplicationTests {
@Autowired
ArrayListSpanReporter accumulator;
@LocalServerPort
int port;
@Test
public void should_not_sample_skipped_endpoint_with_context_path() {
new RestTemplate().getForObject("http://localhost:" + port + "/context-path/actuator/health", String.class);
then(Tracing.current().tracer().currentSpan()).isNull();
then(this.accumulator.getSpans()).hasSize(0); // this fails
}
@EnableAutoConfiguration
@Configuration
public static class Config {
@Bean ArrayListSpanReporter reporter() {
return new ArrayListSpanReporter();
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Context Path vs. Servlet Path in Spring - Baeldung
Simply put, the context path is a name with which a web application is accessed. It is the root of the application. By...
Read more >Web on Servlet Stack - Spring
Spring Web MVC is the original web framework built on the Servlet API and has ... is designed around the front controller pattern...
Read more >Spring Boot not serving static content - Stack Overflow
The class that is responsible for resolving the path, as of Spring 4.1, is org.springframework.web.servlet.resource.PathResourceResolver . Suffix pattern ...
Read more >Defining Tomcat context paths - Octopus Deploy
The context path of a web application defines the URL that end users will ... that is recognised by Java application servers like...
Read more >Apache Tomcat 9 Configuration Reference (9.0.70)
The Context element represents a web application, which is run within a ... all requests that do not match any other Context's context...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Looks like there is still a problem with the fix. Now I’m seeing all endpoints get skipped when a
server.servlet.context-path
is set (because it is appended to the end of the pattern like|context-path.*
). Below is a patch for the integration test that demonstrates the issue.I opened a new issue: https://github.com/spring-cloud/spring-cloud-sleuth/issues/1146
In there I posted my “hack” workaround.