Add ignore amqp consumer#1075
Conversation
Walkthrough新增 ChangesAMQP 消费者忽略功能
Estimated code review effort: 1 (Trivial) | ~5 minutes Sequence Diagram(s)sequenceDiagram
participant Config as sentry.php
participant Listener as EventHandleListener
participant Consumer as ConsumerMessage
Config->>Listener: ignore_amqp_consumer 配置
Consumer->>Listener: 触发 AMQP 消息处理
Listener->>Listener: 检查 message::class 是否在 ignoreAmqpConsumer
alt 命中忽略列表
Listener-->>Consumer: 提前返回,跳过追踪
else 未命中
Listener->>Listener: 继续创建 Sentry 事务
end
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.2.2)PHPStan was skipped because the config uses disallowed 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.
🧹 Nitpick comments (2)
src/sentry/src/Tracing/Listener/EventHandleListener.php (2)
565-568: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value过滤逻辑与
ignore_commands风格不一致:仅支持精确类名匹配
ignoreCommands过滤(Line 373)使用Str::is()支持通配符模式(如gen:*),而这里的ignore_amqp_consumer只能精确匹配完整类名,无法批量忽略某命名空间下的消费者。如果这是有意为之(消费者类名通常固定),可以忽略;否则建议保持一致的通配符支持以提升灵活性。♻️ 可选:支持通配符匹配
- if (in_array($message::class, $this->ignoreAmqpConsumer, true)) { + if (Str::is($this->ignoreAmqpConsumer, $message::class)) { return; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/sentry/src/Tracing/Listener/EventHandleListener.php` around lines 565 - 568, The ignore_amqp_consumer check in EventHandleListener currently uses exact class-name matching only, unlike ignoreCommands which supports wildcard patterns via Str::is(). Update the filtering logic near the message class check to use the same pattern-matching approach if wildcard support is intended, so callers can ignore whole namespaces or class groups consistently. Keep the existing early-return behavior, but make the match logic align with the command filtering style.
68-76: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win建议为新增的过滤逻辑添加测试
ignoreAmqpConsumer的读取与匹配逻辑目前没有看到对应的单元测试。考虑到该功能会直接影响追踪事务的创建与否,建议补充测试覆盖,验证命中忽略列表时提前返回,未命中时正常创建事务。As per coding guidelines, "Maintain type coverage and add/update tests when public APIs change."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/sentry/src/Tracing/Listener/EventHandleListener.php` around lines 68 - 76, 新增的 ignoreAmqpConsumer 过滤逻辑缺少对应测试覆盖。请在 EventHandleListener 相关单测中补充用例,围绕构造函数读取 sentry.ignore_amqp_consumer 以及监听处理流程验证:命中忽略列表时应提前返回且不创建事务,未命中时应继续正常创建事务。优先定位 EventHandleListener、ignoreAmqpConsumer 及其处理 AMQP consumer 事件的入口方法来添加断言。Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/sentry/src/Tracing/Listener/EventHandleListener.php`:
- Around line 565-568: The ignore_amqp_consumer check in EventHandleListener
currently uses exact class-name matching only, unlike ignoreCommands which
supports wildcard patterns via Str::is(). Update the filtering logic near the
message class check to use the same pattern-matching approach if wildcard
support is intended, so callers can ignore whole namespaces or class groups
consistently. Keep the existing early-return behavior, but make the match logic
align with the command filtering style.
- Around line 68-76: 新增的 ignoreAmqpConsumer 过滤逻辑缺少对应测试覆盖。请在 EventHandleListener
相关单测中补充用例,围绕构造函数读取 sentry.ignore_amqp_consumer
以及监听处理流程验证:命中忽略列表时应提前返回且不创建事务,未命中时应继续正常创建事务。优先定位
EventHandleListener、ignoreAmqpConsumer 及其处理 AMQP consumer 事件的入口方法来添加断言。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c95a654f-d982-4a4e-9663-18681a10ecb6
📒 Files selected for processing (2)
src/sentry/publish/sentry.phpsrc/sentry/src/Tracing/Listener/EventHandleListener.php
Summary by CodeRabbit