Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix java.lang.ClassNotFoundException: org.springframework.web.servlet.HandlerMapping in Spring Boot Servlet mode without WebMVC #3336

Merged
merged 5 commits into from
Apr 9, 2024

Conversation

adinauer
Copy link
Member

@adinauer adinauer commented Apr 9, 2024

📜 Description

HandlerMapping is used by SpringMvcTransactionNameProvider. We now provide a fallback TransactionNameProvider which uses the requestURI as transaction name. This means we're not using the route which contains placeholders for IDs (e.g. /todo/{id}) but instead use e.g. /todo/100.

💡 Motivation and Context

Fix-es #1863 (2nd part)

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Copy link
Contributor

github-actions bot commented Apr 9, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 424.08 ms 475.80 ms 51.71 ms
Size 1.70 MiB 2.28 MiB 592.12 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
99a51e2 405.11 ms 479.65 ms 74.54 ms
baaf637 375.71 ms 441.58 ms 65.87 ms
95a98b5 379.14 ms 420.80 ms 41.66 ms
8ff8fd0 432.77 ms 495.18 ms 62.41 ms
937879e 400.98 ms 482.84 ms 81.86 ms
4e29063 376.38 ms 390.98 ms 14.60 ms
28c9a83 366.20 ms 433.88 ms 67.67 ms
0bd723b 412.52 ms 496.65 ms 84.13 ms
93a76ca 377.96 ms 447.52 ms 69.56 ms
a537f8a 457.14 ms 514.19 ms 57.05 ms

App size

Revision Plain With Sentry Diff
99a51e2 1.72 MiB 2.29 MiB 576.34 KiB
baaf637 1.72 MiB 2.27 MiB 558.42 KiB
95a98b5 1.70 MiB 2.27 MiB 586.31 KiB
8ff8fd0 1.72 MiB 2.27 MiB 558.15 KiB
937879e 1.72 MiB 2.27 MiB 558.42 KiB
4e29063 1.72 MiB 2.29 MiB 578.38 KiB
28c9a83 1.70 MiB 2.28 MiB 592.00 KiB
0bd723b 1.72 MiB 2.29 MiB 578.09 KiB
93a76ca 1.72 MiB 2.29 MiB 576.75 KiB
a537f8a 1.70 MiB 2.27 MiB 584.74 KiB

Previous results on branch: fix/missing-handler-mapping-class

Startup times

Revision Plain With Sentry Diff
e52c71c 372.09 ms 445.53 ms 73.44 ms
d9a27b7 388.57 ms 456.52 ms 67.95 ms

App size

Revision Plain With Sentry Diff
e52c71c 1.70 MiB 2.28 MiB 592.05 KiB
d9a27b7 1.70 MiB 2.28 MiB 592.05 KiB

Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look good 👍

Tests need to be adapted, as the ones testing the missing HandlerExceptionResolver fail due to the TransactionNameProvider missing now too.

@@ -300,7 +294,7 @@ public FilterRegistrationBean<SentryTracingFilter> sentryTracingFilter(
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(HandlerExceptionResolver.class)
@Open
static class SentryExceptionResolverConfigurationWrapper {
static class SentryNonServletOnlyModeConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion, but wouldn't something like SentryMvcModeConfig, be more easily understandable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah probably

@@ -298,7 +292,7 @@ public FilterRegistrationBean<SentryTracingFilter> sentryTracingFilter(
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(HandlerExceptionResolver.class)
@Open
static class SentryExceptionResolverConfigurationWrapper {
static class SentryNonServletOnlyModeConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion, but wouldn't something like SentryMvcModeConfig, be more easily understandable?

Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
Added suggestion to add an additional test

@@ -445,6 +447,15 @@ class SentryAutoConfigurationTest {
}
}

@Test
fun `when Spring MVC is not on the classpath, fallback TransactionNameProvider is configured`() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(l) would it make sense to also add a test to assert that, if MVC is used, the SpringMvcTransactionNameProvider is instantiated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we can add this kind of test later to not block this PR.

@@ -444,6 +446,17 @@ class SentryAutoConfigurationTest {
}
}

@Test
fun `when Spring MVC is not on the classpath, fallback TransactionNameProvider is configured`() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(l) would it make sense to also add a test to assert that, if MVC is used, the SpringMvcTransactionNameProvider is instantiated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we can add this kind of test later to not block this PR.

@adinauer adinauer merged commit 39e8942 into main Apr 9, 2024
24 checks passed
@adinauer adinauer deleted the fix/missing-handler-mapping-class branch April 9, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants