Skip to content

Conversation

@huangdijia
Copy link
Contributor

@huangdijia huangdijia commented Nov 11, 2025

Summary

This PR refactors the Sentry configuration structure to improve readability and usability by flattening nested configuration keys and improving method naming conventions.

Configuration Changes

Before:

  • tracing.enable.amqpAfter: tracing.amqp
  • tracing.enable.async_queueAfter: tracing.async_queue
  • tracing.spans.*After: tracing_spans.*
  • tracing.extra_tagsAfter: tracing_tags

API Changes

  • Added Feature::isTracingTagEnabled() method
  • Deprecated Feature::isTracingExtraTagEnabled() (will be removed in v3.2)
  • Updated Switcher::isTracingExtraTagEnable() to use the new method internally

Implementation Details

  • Updated configuration file structure in publish/sentry.php
  • Modified ClientBuilderFactory to include new configuration keys
  • Updated all tracing aspects to use isTracingTagEnabled() instead of isTracingExtraTagEnabled()
  • Updated event listeners to use new configuration structure
  • Updated tests to reflect new configuration paths

Benefits

  • Improved readability: Reduced nesting depth in configuration
  • Better naming: tracing_tags is clearer than extra_tags
  • Consistent API: Unified method naming with Enabled suffix
  • Backward compatible: Deprecated methods still work with warnings

Breaking Changes

None - all changes are backward compatible through deprecation notices.

Test plan

  • All existing tests pass with updated configuration
  • Configuration structure has been flattened and simplified
  • All internal usages updated to new methods
  • Deprecated methods still function correctly

Summary by CodeRabbit

发行说明

  • 重构

    • 简化追踪配置结构,从嵌套式改为扁平式组织
    • 引入新的公开配置键:tracing_spanstracing_tags
    • 更新追踪标签检查机制,统一使用新的方法名称
  • 测试

    • 更新测试用例以适配新的配置结构

…ming

This refactoring flattens the nested tracing configuration structure and improves method naming for better usability:

- Flatten `tracing.enable.*` to `tracing.*` (e.g., `tracing.enable.amqp` → `tracing.amqp`)
- Move `tracing.spans.*` to top-level `tracing_spans.*`
- Rename `tracing.extra_tags` to `tracing_tags` for clarity
- Add `isTracingTagEnabled()` method and deprecate `isTracingExtraTagEnabled()`
- Update all internal usages to use the new configuration structure
- Update tests to reflect the new configuration paths

This change improves configuration readability and reduces nesting depth while maintaining backward compatibility through deprecation warnings.
@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Warning

Rate limit exceeded

@huangdijia has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 8 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f337e44 and 595213c.

📒 Files selected for processing (1)
  • src/sentry/src/Listener/SetupSentryListener.php (1 hunks)

Walkthrough

本PR重构了Sentry跟踪配置结构,将嵌套的tracing配置(enable、spans、extra_tags)扁平化为顶级键,并引入新的tracing_spans和tracing_tags配置组。同时将特征标志检查从isTracingExtraTagEnabled统一改为isTracingTagEnabled。

Changes

Cohort / File(s) 变更摘要
配置结构重构
src/sentry/publish/sentry.php
扁平化tracing配置:将tracing.enable、tracing.spans、tracing.extra_tags替换为顶级tracing键和新的tracing_spans、tracing_tags配置组
工厂类更新
src/sentry/src/Factory/ClientBuilderFactory.php
在SPECIFIC_OPTIONS常量中添加tracing_spans和tracing_tags以处理新的配置键
特征标志API更新
src/sentry/src/Feature.php
添加新方法isTracingTagEnabled()以从tracing_tags配置读取;重构isTracingEnabled()以使用新的配置路径;弃用isTracingExtraTagEnabled()
弃用包装器更新
src/sentry/src/Switcher.php
将isTracingExtraTagEnable委托到isTracingTagEnabled;更新弃用文档
数据库追踪方面
src/sentry/src/Tracing/Aspect/DbAspect.php
将特征标志检查从isTracingExtraTagEnabled()改为isTracingTagEnabled()以控制数据库绑定和结果数据的记录
Elasticsearch追踪方面
src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php
替换特征标志检查从isTracingExtraTagEnabled()改为isTracingTagEnabled()以控制结果标签
Guzzle HTTP追踪方面
src/sentry/src/Tracing/Aspect/GuzzleHttpClientAspect.php
替换特征标志检查从isTracingExtraTagEnabled()改为isTracingTagEnabled()以控制HTTP响应体内容标签
Redis追踪方面
src/sentry/src/Tracing/Aspect/RedisAspect.php
替换特征标志检查从isTracingExtraTagEnabled()改为isTracingTagEnabled()以控制结果数据附加
RPC追踪方面
src/sentry/src/Tracing/Aspect/RpcAspect.php
替换特征标志检查从isTracingExtraTagEnabled()改为isTracingTagEnabled()
追踪注解方面
src/sentry/src/Tracing/Aspect/TraceAnnotationAspect.php
替换特征标志检查从isTracingExtraTagEnabled()改为isTracingTagEnabled()
事件处理监听器
src/sentry/src/Tracing/Listener/EventHandleListener.php
将特征标志检查从isTracingExtraTagEnabled()改为isTracingTagEnabled()以控制多个数据库和Redis相关标签
单元测试更新
tests/Sentry/FeatureTest.php
更新测试配置键从tracing改为tracing_tags;更新API调用从isTracingExtraTagEnabled()改为isTracingTagEnabled();添加新的测试用例

Sequence Diagram(s)

sequenceDiagram
    actor User as 用户代码
    participant Feature as Feature 类
    participant Config as 配置系统

    User->>Feature: isTracingTagEnabled('db.sql.bindings')
    activate Feature
    Note over Feature: 新API路径
    Feature->>Config: 读取 sentry.tracing_tags['db.sql.bindings']
    Config-->>Feature: 返回标志值
    Feature-->>User: 返回布尔值
    deactivate Feature

    Note over Feature: 旧API (已弃用)
    User->>Feature: isTracingExtraTagEnabled('db.sql.bindings')
    activate Feature
    Feature->>Feature: 委托到 isTracingTagEnabled()
    Feature-->>User: 返回布尔值
    deactivate Feature
Loading
sequenceDiagram
    participant DbAspect as DbAspect
    participant Feature as Feature
    participant Span as Span

    DbAspect->>Feature: isTracingTagEnabled('db.sql.bindings', true)
    Feature-->>DbAspect: true/false
    
    alt 标志启用
        DbAspect->>Span: 设置 sql.bindings 数据
    else 标志禁用
        Note over DbAspect: 跳过 sql.bindings 数据
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

需要额外关注的区域:

  • src/sentry/src/Feature.php — 新方法isTracingTagEnabled()的实现与多个Aspect的配置路径整合
  • src/sentry/publish/sentry.php — 配置结构的扁平化是否完整且向后兼容性处理
  • src/sentry/src/Tracing/Aspect/*.php — 需验证所有8个Aspect文件中的特征标志替换是否正确且完整
  • tests/Sentry/FeatureTest.php — 测试数据是否覆盖新的tracing_tags配置结构中的所有场景

Possibly related PRs

Suggested reviewers

  • xuanyanwow

Poem

🐰✨ 一条聪慧的兔子来临,
配置扁平,标签统一清晰,
Extra_tags 变 tracing_tags 映,
新API引路,追踪更明净,
代码重构,功能不变分毫!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.76% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确反映了主要变更:简化配置结构和改进API命名,这正是PR的核心目标。

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 14cc8a2 into main Nov 11, 2025
22 checks passed
huangdijia added a commit that referenced this pull request Nov 11, 2025
…ming (#991)

* refactor(sentry): simplify configuration structure and improve API naming

This refactoring flattens the nested tracing configuration structure and improves method naming for better usability:

- Flatten `tracing.enable.*` to `tracing.*` (e.g., `tracing.enable.amqp` → `tracing.amqp`)
- Move `tracing.spans.*` to top-level `tracing_spans.*`
- Rename `tracing.extra_tags` to `tracing_tags` for clarity
- Add `isTracingTagEnabled()` method and deprecate `isTracingExtraTagEnabled()`
- Update all internal usages to use the new configuration structure
- Update tests to reflect the new configuration paths

This change improves configuration readability and reduces nesting depth while maintaining backward compatibility through deprecation warnings.

* refactor(sentry): update tracing configuration keys for consistency and clarity

---------

Co-Authored-By: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
@huangdijia huangdijia deleted the refactor/sentry-config-structure branch November 11, 2025 05:26
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