Skip to content

Conversation

@huangdijia
Copy link
Contributor

@huangdijia huangdijia commented Nov 11, 2025

Summary

This PR adds a backwards compatibility layer for legacy Sentry configuration keys to ensure a smooth migration path for users upgrading from previous versions.

Changes

  • Added compatibilityConfigurations() method to handle legacy config migration
  • Maps sentry.tracing.spanssentry.tracing_spans
  • Maps sentry.tracing.extra_tagssentry.tracing_tags
  • Migrates sentry.tracing.enable.* to flat sentry.tracing.* structure

Context

Recent refactoring simplified the Sentry configuration structure (#991, #990). This PR ensures that existing configurations using the old structure continue to work without requiring immediate migration.

Test Plan

  • Verify old configuration keys (sentry.tracing.spans, sentry.tracing.extra_tags, sentry.tracing.enable) are properly migrated
  • Verify new configuration structure works as expected
  • Verify no breaking changes for existing users

Summary by CodeRabbit

Bug Fixes

  • 改进了配置系统的向后兼容性处理,确保旧的配置键在升级时能够自动迁移至新格式,保持现有配置的正常运作。

Add compatibility layer to support old Sentry configuration structure while maintaining new API. This ensures smooth migration path for users upgrading from previous versions.

Changes:
- Map `sentry.tracing.spans` to `sentry.tracing_spans`
- Map `sentry.tracing.extra_tags` to `sentry.tracing_tags`
- Migrate `sentry.tracing.enable.*` to flat `sentry.tracing.*` structure
- Add `compatibilityConfigurations()` method to handle legacy config migration

This maintains backwards compatibility while supporting the simplified configuration structure introduced in recent refactoring.
@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 19 minutes and 16 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 1e5d461 and f99934c.

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

总览

SetupSentryListener 类中引入了 compatibilityConfigurations() 方法,用于运行时迁移旧式配置键。该方法将嵌套的 sentry.tracing.* 配置键映射到新的扁平化配置键,并在 process() 方法启动时执行,确保配置兼容性。

变更

队列 / 文件 变更摘要
配置兼容性迁移
src/sentry/src/Listener/SetupSentryListener.php
添加 compatibilityConfigurations() 受保护方法,处理三种配置迁移场景:sentry.tracing.spanssentry.tracing_spanssentry.tracing.extra_tagssentry.tracing_tagssentry.tracing.enable 动态配置。在 process() 方法开始处调用以确保配置优先级。

代码审查工作量评估

🎯 2 (简单) | ⏱️ ~8 分钟

  • 单一文件修改,逻辑清晰
  • 新增方法的实现为直观的配置键值迁移和复制操作
  • 需要验证配置键映射的正确性和迁移逻辑的完整性
  • 确认 process() 方法中的调用位置不会引入回归问题

相关的 PR

  • PR #990: 主 PR 添加了旧版 sentry.tracing.* 配置的运行时迁移,而该 PR 移除了已发布配置中的已弃用 enable_tracing 选项,两者都涉及同一配置表面。
  • PR #935: 两个 PR 都涉及相同的 Sentry 追踪配置键:主 PR 迁移/规范化 tracing.spans 和相关 tracing.* 键,该 PR 在 tracing.spans 下添加新的 'view' 条目。
  • PR #991: 主 PR 添加的运行时兼容性逻辑将旧的嵌套追踪配置键(如 sentry.tracing.spanssentry.tracing.extra_tagssentry.tracing.enable.*)迁移到该 PR 引入的扁平化键(tracing_spanstracing_tagssentry.tracing.{key})。

🐰 旧配置重生,兼容新时代,
键值翻飞,映射成行,
compatibilityConfigurations 展翅翔舞,
启动之始,配置已准妥,
迁移无忧,向未来而行!✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 标题清晰准确地总结了主要变更:为Sentry添加向后兼容性支持,与代码变更内容完全相符。

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.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 14cc8a2 and 1e5d461.

📒 Files selected for processing (1)
  • src/sentry/src/Listener/SetupSentryListener.php (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/*/src/**/*.php

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

All component PHP code must use the namespace pattern FriendsOfHyperf{ComponentName}

Files:

  • src/sentry/src/Listener/SetupSentryListener.php
**/*.php

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.php: Code style must follow PSR-12 and be formatted by PHP-CS-Fixer per .php-cs-fixer.php
Run PHPStan and keep the codebase passing per phpstan.neon.dist

Files:

  • src/sentry/src/Listener/SetupSentryListener.php
⏰ 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). (17)
  • GitHub Check: Test on PHP 8.1 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.2 with Swoole 6.1.1
  • GitHub Check: Test on PHP 8.1 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.1 with Swoole 6.1.1
  • GitHub Check: Test on PHP 8.2 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.2 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.1
  • GitHub Check: Test on PHP 8.2 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.1 with Swoole 6.1.1
  • GitHub Check: Test on PHP 8.3 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.3 with Swoole 6.1.1
  • GitHub Check: Test on PHP 8.1 with Swoole 5.1.8
  • GitHub Check: Test on PHP 8.2 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.2 with Swoole 6.1.1
  • GitHub Check: Test on PHP 8.3 with Swoole 6.0.2
🔇 Additional comments (3)
src/sentry/src/Listener/SetupSentryListener.php (3)

81-81: 调用时机正确。

process() 方法开始时调用配置兼容性处理是合理的,确保在其他设置步骤之前完成配置迁移。


90-92: 迁移逻辑正确。

正确地检查了源键存在且目标键不存在的情况,避免了覆盖用户的新配置。


94-96: 迁移逻辑正确。

与第一个迁移保持一致,正确地处理了配置键的迁移。

@huangdijia huangdijia merged commit 7937cad into main Nov 11, 2025
22 checks passed
@huangdijia huangdijia deleted the feat/sentry-config-compatibility branch November 11, 2025 05:24
huangdijia added a commit that referenced this pull request Nov 11, 2025
…ys (#992)

* feat(sentry): add backwards compatibility for legacy configuration keys

Add compatibility layer to support old Sentry configuration structure while maintaining new API. This ensures smooth migration path for users upgrading from previous versions.

Changes:
- Map `sentry.tracing.spans` to `sentry.tracing_spans`
- Map `sentry.tracing.extra_tags` to `sentry.tracing_tags`
- Migrate `sentry.tracing.enable.*` to flat `sentry.tracing.*` structure
- Add `compatibilityConfigurations()` method to handle legacy config migration

This maintains backwards compatibility while supporting the simplified configuration structure introduced in recent refactoring.

* refactor(sentry): streamline compatibility configuration mapping for tracing keys

---------

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