-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
support sofa thread pool actuator #1301
support sofa thread pool actuator #1301
Conversation
2. support sofa thread pool actuator
WalkthroughThe recent updates introduce a Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files ignored due to path filters (1)
sofa-boot-project/sofaboot-dependencies/pom.xml
is excluded by:!**/*.xml
Files selected for processing (7)
- sofa-boot-project/sofa-boot-actuator-autoconfigure/src/main/java/com/alipay/sofa/boot/actuator/autoconfigure/threadpool/ThreadPoolEndpointAutoConfiguration.java (1 hunks)
- sofa-boot-project/sofa-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports (1 hunks)
- sofa-boot-project/sofa-boot-actuator-autoconfigure/src/test/java/com/alipay/sofa/boot/actuator/autoconfigure/threadpool/ThreadPoolEndpointAutoConfigurationTests.java (1 hunks)
- sofa-boot-project/sofa-boot-actuator/src/main/java/com/alipay/sofa/boot/actuator/threadpool/ThreadPoolEndpoint.java (1 hunks)
- sofa-boot-project/sofa-boot-actuator/src/test/java/com/alipay/sofa/boot/actuator/threadpool/ThreadPoolEndpointTests.java (1 hunks)
- sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/constant/SofaBootConstants.java (1 hunks)
- sofa-boot-tests/sofa-boot-smoke-tests/sofa-boot-smoke-tests-actuator/src/test/java/com/alipay/sofa/smoke/tests/actuator/threadpool/ThreadPoolEndpointWebTests.java (1 hunks)
Additional comments: 2
sofa-boot-project/sofa-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports (1)
- 11-11: The addition of
ThreadPoolEndpointAutoConfiguration
to the auto-configuration imports list is correctly implemented and aligns with the PR's objective to introduce a thread pool actuator. This ensures that Spring Boot's auto-configuration mechanism will automatically configure theThreadPoolEndpoint
when conditions are met.sofa-boot-project/sofa-boot-actuator-autoconfigure/src/test/java/com/alipay/sofa/boot/actuator/autoconfigure/threadpool/ThreadPoolEndpointAutoConfigurationTests.java (1)
- 38-47: The tests for
ThreadPoolEndpointAutoConfiguration
are well-implemented, correctly simulating the conditions under which theThreadPoolEndpoint
bean should and should not be created. These tests effectively validate the auto-configuration logic.
@ConditionalOnAvailableEndpoint(endpoint = ThreadPoolEndpoint.class) | ||
public class ThreadPoolEndpointAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public ThreadPoolEndpoint threadPoolEndpoint() { | ||
return new ThreadPoolEndpoint(ThreadPoolGovernor.getInstance()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The auto-configuration class for ThreadPoolEndpoint
is correctly implemented with appropriate conditions to ensure it's only configured when available and not already defined. However, adding documentation for the threadPoolEndpoint
method could improve code maintainability and clarity for future developers.
+ /**
+ * Creates a ThreadPoolEndpoint bean if one does not already exist.
+ * @return ThreadPoolEndpoint instance
+ */
@Bean
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
@ConditionalOnAvailableEndpoint(endpoint = ThreadPoolEndpoint.class) | |
public class ThreadPoolEndpointAutoConfiguration { | |
@Bean | |
@ConditionalOnMissingBean | |
public ThreadPoolEndpoint threadPoolEndpoint() { | |
return new ThreadPoolEndpoint(ThreadPoolGovernor.getInstance()); | |
} | |
@ConditionalOnAvailableEndpoint(endpoint = ThreadPoolEndpoint.class) | |
public class ThreadPoolEndpointAutoConfiguration { | |
/** | |
* Creates a ThreadPoolEndpoint bean if one does not already exist. | |
* @return ThreadPoolEndpoint instance | |
*/ | |
@Bean | |
@ConditionalOnMissingBean | |
public ThreadPoolEndpoint threadPoolEndpoint() { | |
return new ThreadPoolEndpoint(ThreadPoolGovernor.getInstance()); | |
} |
@Test | ||
public void threadPoolActuator() { | ||
ResponseEntity<String> response = restTemplate.getForEntity("/actuator/threadpool", String.class); | ||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
assertThat(response.getBody()) | ||
.contains(""" | ||
{"threadPoolName":"demoThreadPool","threadPoolClassName":"com.alipay.sofa.common.thread.SofaThreadPoolExecutor","coreSize":20,"maxSize":20,"queueClassName":"java.util.concurrent.LinkedBlockingQueue","queueSize":0,"queueRemainingCapacity":10,"monitorPeriod":5000,"taskTimeout":30000}"""); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The integration test for the ThreadPoolEndpoint
web response is correctly implemented, effectively verifying the endpoint's functionality in a live application context. However, adding a comment explaining the purpose of the custom thread pool bean sofaThreadPoolExecutor
could enhance clarity for future developers.
+ /**
+ * Defines a custom thread pool bean for testing the ThreadPoolEndpoint.
+ * @return SofaThreadPoolExecutor instance
+ */
@Bean
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
@Test | |
public void threadPoolActuator() { | |
ResponseEntity<String> response = restTemplate.getForEntity("/actuator/threadpool", String.class); | |
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); | |
assertThat(response.getBody()) | |
.contains(""" | |
{"threadPoolName":"demoThreadPool","threadPoolClassName":"com.alipay.sofa.common.thread.SofaThreadPoolExecutor","coreSize":20,"maxSize":20,"queueClassName":"java.util.concurrent.LinkedBlockingQueue","queueSize":0,"queueRemainingCapacity":10,"monitorPeriod":5000,"taskTimeout":30000}"""); | |
} | |
@Test | |
public void threadPoolActuator() { | |
ResponseEntity<String> response = restTemplate.getForEntity("/actuator/threadpool", String.class); | |
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); | |
assertThat(response.getBody()) | |
.contains(""" | |
{"threadPoolName":"demoThreadPool","threadPoolClassName":"com.alipay.sofa.common.thread.SofaThreadPoolExecutor","coreSize":20,"maxSize":20,"queueClassName":"java.util.concurrent.LinkedBlockingQueue","queueSize":0,"queueRemainingCapacity":10,"monitorPeriod":5000,"taskTimeout":30000}"""); | |
} | |
/** | |
* Defines a custom thread pool bean for testing the ThreadPoolEndpoint. | |
* @return SofaThreadPoolExecutor instance | |
*/ | |
@Bean |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1301 +/- ##
============================================
+ Coverage 82.99% 83.06% +0.07%
- Complexity 2945 2955 +10
============================================
Files 333 335 +2
Lines 9674 9697 +23
Branches 1168 1168
============================================
+ Hits 8029 8055 +26
+ Misses 1136 1132 -4
- Partials 509 510 +1 ☔ View full report in Codecov by Sentry. |
2. support sofa thread pool actuator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- sofa-boot-project/sofa-boot-actuator-autoconfigure/src/main/java/com/alipay/sofa/boot/actuator/autoconfigure/threadpool/ThreadPoolEndpointAutoConfiguration.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- sofa-boot-project/sofa-boot-actuator-autoconfigure/src/main/java/com/alipay/sofa/boot/actuator/autoconfigure/threadpool/ThreadPoolEndpointAutoConfiguration.java
1. update sofa-common-tools 2.1.1 2. support sofa thread pool actuator --------- Co-authored-by: 致节 <hzj266771@antgroup.com>
Summary by CodeRabbit
ThreadPoolEndpoint
for viewing thread pool configurations and statuses.ThreadPoolEndpoint
.ThreadPoolEndpoint
in the list of auto-configured endpoints for improved clarity.