Skip to content

Conversation

@huangdijia
Copy link
Contributor

@huangdijia huangdijia commented Nov 14, 2025

Summary

  • Add Hyperf\Coroutine\wait and wait to skip functions list
  • Add FriendsOfHyperf\Sentry\Transport\CoHttpTransport->loop to break functions list

Details

This PR improves the accuracy of backtrace filtering for Sentry error reporting by including additional coroutine-related functions that should be handled during stack trace analysis:

  1. Skip Functions: Added Hyperf\Coroutine\wait and wait to ensure these coroutine utility functions are properly skipped during backtrace processing
  2. Break Functions: Added FriendsOfHyperf\Sentry\Transport\CoHttpTransport->loop to treat this transport loop as a break point in the stack trace

These changes ensure cleaner and more meaningful stack traces are reported to Sentry by filtering out internal coroutine management functions.

Test plan

  • Verified the changes compile without errors
  • Tested with Sentry error reporting to confirm improved backtrace filtering
  • Verified that the new functions are correctly filtered in stack traces

Summary by CodeRabbit

  • Bug Fixes
    • 改进了错误追踪的堆栈跟踪处理机制,增强了异步操作环境下错误信息的采集和分析能力。

- Add 'Hyperf\Coroutine\wait' and 'wait' to skip functions list
- Add 'FriendsOfHyperf\Sentry\Transport\CoHttpTransport->loop' to break functions list

This improves the accuracy of backtrace filtering for Sentry error reporting by including additional coroutine-related functions that should be skipped or treated as break points during stack trace analysis.
@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

详细概述

Walkthrough

CoroutineBacktraceHelper.php 中更新了协程回溯跟踪的函数配置:在 skipFunctions 数组中新增 Hyperf\Coroutine\wait 及其别名,在 breakFunctions 数组中新增 CoHttpTransport->loop 方法。

Changes

类别 / 文件 变更摘要
协程回溯辅助工具配置
src/sentry/src/Util/CoroutineBacktraceHelper.php
在 skipFunctions 数组中添加 Hyperf\Coroutine\waitwait 别名;在 breakFunctions 数组中添加 FriendsOfHyperf\Sentry\Transport\CoHttpTransport->loop

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • 变更范围小且集中在单一文件中,仅涉及配置数组的追加操作
  • 无复杂逻辑或控制流修改
  • 需要验证新增函数名称的正确性和是否完整覆盖相关协程操作

Possibly related PRs

Poem

🐰 Hyperf 协程轻飘飘,
等待函数已标标,
回溯追踪更精妙,
传输循环断点照,
堆栈清晰不凌乱!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确概括了变更的核心内容:改进Sentry中协程堆栈跟踪的过滤功能。标题简洁明了,与代码变更(添加跳过函数和中断点)相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/sentry-improve-coroutine-backtrace-filtering

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4460c20 and 46d6eb9.

📒 Files selected for processing (1)
  • src/sentry/src/Util/CoroutineBacktraceHelper.php (1 hunks)
⏰ 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). (18)
  • GitHub Check: Test on PHP 8.1 with Swoole 6.1.2
  • GitHub Check: Test on PHP 8.1 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.2 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.2 with Swoole 6.1.2
  • GitHub Check: Test on PHP 8.1 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.3 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.3 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.3 with Swoole 6.1.2
  • GitHub Check: Test on PHP 8.2 with Swoole 6.0.2
  • 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.1 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.3 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.1 with Swoole 6.1.2
  • GitHub Check: Test on PHP 8.2 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.2 with Swoole 6.1.2
  • GitHub Check: Test on PHP 8.3 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.3 with Swoole 6.1.2
🔇 Additional comments (3)
src/sentry/src/Util/CoroutineBacktraceHelper.php (3)

16-39: 整体变更结构合理,建议完成集成测试。

两处配置添加的格式和位置都正确:

  • skipFunctions 用于过滤不需要显示的协程工具函数
  • breakFunctions 用于标记回溯扫描的中断点

根据 PR 目标描述,Sentry 集成测试和新函数过滤的验证尚未完成。建议在合并前完成这些测试,以确保:

  1. 新添加的函数在实际场景中被正确过滤
  2. 回溯信息的可读性得到改善
  3. 没有引入意外的副作用

31-31: 代码变更验证完成,无需进一步修改。

验证已确认 CoHttpTransport 类及其 loop() 方法均存在:

  • 类定义:src/sentry/src/Transport/CoHttpTransport.php:31
  • 命名空间:FriendsOfHyperf\Sentry\Transport(与引用完全匹配)
  • 方法定义:src/sentry/src/Transport/CoHttpTransport.php:74 (protected function)

添加到 breakFunctions 数组的格式正确,与现有条目(如 HttpClient->loop)保持一致。该变更无问题。


24-24: 变更已验证正确,无需修改。

两处添加都已确认存在于代码库中:

行24Hyperf\Coroutine\wait 函数在 vendor/hyperf/coroutine/src/Functions.php 中定义,是协程工具函数,正确添加到 skipFunctions 数组以在回溯过程中跳过。

行31CoHttpTransport->loop 方法在 src/sentry/src/Transport/CoHttpTransport.php 中实现,正确添加到 breakFunctions 数组以作为回溯断点。

两处变更的格式一致、语法正确、逻辑合理。

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.31)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@huangdijia huangdijia merged commit a2abb20 into main Nov 14, 2025
22 of 23 checks passed
@huangdijia huangdijia deleted the feat/sentry-improve-coroutine-backtrace-filtering branch November 14, 2025 03:52
huangdijia added a commit that referenced this pull request Nov 14, 2025
- Add 'Hyperf\Coroutine\wait' and 'wait' to skip functions list
- Add 'FriendsOfHyperf\Sentry\Transport\CoHttpTransport->loop' to break functions list

This improves the accuracy of backtrace filtering for Sentry error reporting by including additional coroutine-related functions that should be skipped or treated as break points during stack trace analysis.

Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
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