-
-
Notifications
You must be signed in to change notification settings - Fork 27
refactor(sentry): simplify hub initialization in Tracer #934
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
refactor(sentry): simplify hub initialization in Tracer #934
Conversation
- Replace complex tap-based hub cloning with direct SentrySdk::init() - Remove unused imports: HubInterface and tap function - Simplify startTransaction method while maintaining functionality - Improve code readability and reduce dependencies
Walkthrough在 Tracer::startTransaction 中,将原先基于克隆并 setCurrentHub/tap 的 Hub 初始化流程,改为先调用 init() 创建 Hub,再调用 pushScope()。移除未使用的 HubInterface 与 tap 相关导入,其他事务启动与数据填充逻辑保持不变。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller as 调用方
participant Tracer as Tracer::startTransaction
participant Sentry as Sentry SDK
participant Hub as Hub
participant Scope as Scope
Caller->>Tracer: startTransaction(ctx)
Tracer->>Sentry: init() // 新:直接初始化 Hub
Sentry-->>Tracer: Hub
Tracer->>Hub: pushScope() // 新:显式入栈作用域
Tracer->>Hub: startTransaction(ctx)
Hub-->>Tracer: Transaction
Tracer-->>Caller: Transaction
note over Tracer,Hub: 变更点:不再使用 setCurrentHub(克隆+tap),改为 init()+pushScope()
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
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 |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/sentry/src/Tracing/Tracer.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/sentry/src/Tracing/Tracer.php (1)
src/sentry/class_map/SentrySdk.php (1)
SentrySdk(24-65)
⏰ 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). (9)
- GitHub Check: Test on PHP 8.1 with Swoole 5.1.7
- GitHub Check: Test on PHP 8.1 with Swoole 6.0.2
- GitHub Check: Test on PHP 8.2 with Swoole 6.0.2
- GitHub Check: Test on PHP 8.3 with Swoole 6.0.2
- GitHub Check: Test on PHP 8.2 with Swoole 5.1.7
- GitHub Check: Test on PHP 8.3 with Swoole 5.1.7
- GitHub Check: Test on PHP 8.1 with Swoole 5.1.7
- GitHub Check: Test on PHP 8.3 with Swoole 5.1.7
- GitHub Check: Test on PHP 8.2 with Swoole 5.1.7
- Replace complex tap-based hub cloning with direct SentrySdk::init() - Remove unused imports: HubInterface and tap function - Simplify startTransaction method while maintaining functionality - Improve code readability and reduce dependencies Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
Summary
Changes
tap(clone SentrySdk::getCurrentHub(), fn (HubInterface $hub) => $hub->pushScope())with simplerSentrySdk::init()and$hub->pushScope()Sentry\State\HubInterfaceandfunction Hyperf\Tappable\tapTest plan
Summary by CodeRabbit