-
-
Notifications
You must be signed in to change notification settings - Fork 27
refactor(sentry): optimize event flushing strategy by moving to tracing components #940
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
Conversation
…ng components - Remove flushEvents() method and calls from main EventHandleListener - Move event flushing responsibility to tracing components where transactions finish - Clean up commented code in CoroutineAspect files - Ensure events are flushed at appropriate transaction boundaries for better performance This change improves the efficiency of Sentry event handling by flushing events only when tracing transactions complete, rather than after every event.
Walkthrough在常规与追踪两个模块中,调整协程上下文与事件处理的刷新策略:移除非追踪监听器中的批量 flush 方法与调用;在追踪相关的协程和事件 defer 收尾阶段完成事务后统一调用 Integration::flushEvents();精简协程上下文复制的键集合。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as 应用代码
participant Tracer as Tracing Listener/Aspect
participant Scope as Sentry Scope
participant Tx as Transaction
participant Int as Integration
App->>Tracer: 触发事件/进入协程
Tracer->>Scope: 获取当前事务
alt 存在事务
Scope->>Tx: 使用活动事务
else
Note over Tracer: 无事务则仅继续执行
end
App-->>App: 执行业务逻辑
rect rgba(230,245,255,0.6)
note right of Tracer: defer 收尾(新/变更)
Tracer->>Scope: 确保设置活动事务
Tracer->>Tx: finish()
Tracer->>Int: flushEvents()
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
💤 Files with no reviewable changes (2)
🧰 Additional context used📓 Path-based instructions (3)src/*/src/**/*.php📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
{src,tests}/**/*.php📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
src/*/**📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧬 Code graph analysis (2)src/sentry/src/Tracing/Listener/EventHandleListener.php (1)
src/sentry/src/Tracing/Aspect/CoroutineAspect.php (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.1.28)At least one path must be specified to analyse. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ng components (#940) - Remove flushEvents() method and calls from main EventHandleListener - Move event flushing responsibility to tracing components where transactions finish - Clean up commented code in CoroutineAspect files - Ensure events are flushed at appropriate transaction boundaries for better performance This change improves the efficiency of Sentry event handling by flushing events only when tracing transactions complete, rather than after every event. Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
Summary
This PR optimizes the Sentry event flushing strategy by moving the responsibility from general event listeners to tracing-specific components, resulting in more efficient event handling.
Changes Made
flushEvents()method and all its calls fromEventHandleListenerCoroutineAspectandEventHandleListenerin tracing namespace)Benefits
Files Modified
src/sentry/src/Aspect/CoroutineAspect.php: Removed commented codesrc/sentry/src/Listener/EventHandleListener.php: RemovedflushEvents()method and callssrc/sentry/src/Tracing/Aspect/CoroutineAspect.php: Added event flushing in defer blocksrc/sentry/src/Tracing/Listener/EventHandleListener.php: Added event flushing after transaction completionTesting
This change maintains the same functionality while improving performance. Events will still be properly flushed, but at more appropriate times (when transactions complete).
Impact
Summary by CodeRabbit
Bug Fixes
Refactor