Skip to content

Add ignore amqp consumer#1075

Closed
xuanyanwow wants to merge 1 commit into
mainfrom
add_ignore_amqp_consumer
Closed

Add ignore amqp consumer#1075
xuanyanwow wants to merge 1 commit into
mainfrom
add_ignore_amqp_consumer

Conversation

@xuanyanwow

@xuanyanwow xuanyanwow commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • 新功能
    • 新增可配置的 AMQP 消费者忽略列表,支持跳过指定消息类型的追踪。
  • 改进
    • 对被忽略的消费事件将不再生成相关 Sentry 事务,减少无关监控数据。

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

新增 ignore_amqp_consumer 配置项,用于指定需要忽略 Sentry 追踪的 AMQP 消费者类。EventHandleListener 在构造时读取该配置,并在处理 AMQP 消息时对匹配的消费者类提前返回,跳过后续追踪事务创建。

Changes

AMQP 消费者忽略功能

Layer / File(s) Summary
配置与过滤逻辑
src/sentry/publish/sentry.php, src/sentry/src/Tracing/Listener/EventHandleListener.php
新增 ignore_amqp_consumer 配置数组,EventHandleListener 构造函数读取并转换为数组,在 AMQP 消息处理中命中该列表时提前返回跳过追踪。

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
Loading

Poem

兔子巡逻消息队列间,
遇到黑名单轻轻跳过,
不留追踪不留痕,
蹦跳而去继续忙 🐇
配置一行,清净心安~

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题与本次新增 AMQP 消费者忽略配置及其处理逻辑一致,能概括主要变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add_ignore_amqp_consumer

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 bootstrapFiles, bootstrapFile, or includes directives.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9a48f4a and adedc8f.

📒 Files selected for processing (2)
  • src/sentry/publish/sentry.php
  • src/sentry/src/Tracing/Listener/EventHandleListener.php

@xuanyanwow xuanyanwow closed this Jul 3, 2026
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.

1 participant