-
[NA] [BE] Add OpenTelemetry metrics to RateLimitInterceptor with HTTP route and method attributes (#3836)
发布于
2025-10-29 08:20:54 +00:00 - [NA] [BE] Refactor webhook async handling and resource management
-
WebhookSubscriber: Fixed 5 async/non-blocking issues
- Replaced Mono.fromRunnable with Mono.fromCallable for proper exception handling
- Wrapped blocking deserialization with Mono.fromCallable + subscribeOn
- Moved attributes building inside Mono chain
- Pre-built metrics counters to avoid repeated instantiation
- Added timeout and validated HTTP client usage
-
BaseRedisSubscriber: Added backpressure monitoring
- Added pre-built backpressure drop counter
- Logs when backpressure causes events to be dropped
- Helps identify system overload conditions
-
WebhookHttpClient: Major async/resource management improvements
- Async JSON serialization on boundedElastic scheduler
- Try-with-resources for automatic response cleanup
- Optional for null-safe string handling
- Retry attempt logging for observability
- Returns response body or 'ok' instead of exposing Response object
- No duplicate error logging
-
AlertService: Updated to work with new Mono return type
- Handles response body directly
- Defaults to 200 status code on success
All changes follow reactive best practices and enterprise-grade patterns.
-
Revision 2: Address all 8 GitHub PR comments - fix reactive chain, remove unnecessary wrappers, consolidate schedulers, fix resource management, and clarify logging messages
-
Revision 3: Use try-with-resources for cleaner Resource management in async callback
-
Revision 4: Simplify try-with-resources syntax using Java 9+ style
-
Revision 5: Address 4 new Copilot comments - use parallel() for CPU-bound JSON work, remove misleading comment, simplify validation with Mono.fromRunnable()
-
Revision 6: Keep boundedElastic() for JSON work - better migration path for future virtual threads
-
Revision 7: Use parallel() for short CPU-bound JSON work - not suitable for virtual threads
-
Revision 8: Use boundedElastic() consistently - project has virtual threads support (enableVirtualThreads flag) for future efficiency
-
[NA] [BE] Fix webhook async handling - restore original working structure with proper error handling
-
[NA] [BE] Add OpenTelemetry metrics to RateLimitInterceptor with HTTP route and method attributes
下载附件