Skip to content

Conversation

@huangdijia
Copy link
Contributor

@huangdijia huangdijia commented Oct 12, 2025

Summary

This PR updates the GrpcAspect to align with OpenTelemetry semantic conventions for RPC spans:

  • Operation name: Changed from grpc.client to rpc.client
  • Origin: Updated from auto.grpc to auto.rpc
  • Span attributes: Renamed to follow OTel conventions:
    • grpc.methodrpc.method
    • grpc.optionsrpc.options
    • Added rpc.system attribute set to grpc

These changes improve compatibility with OpenTelemetry standards and observability tools that expect standard RPC span naming conventions.

Test plan

  • Verify existing gRPC tracing functionality continues to work
  • Confirm span attributes are correctly populated in Sentry dashboard
  • Check that the rpc.system attribute is set to grpc
  • Validate that operation name appears as rpc.client in traces
  • Ensure no breaking changes to existing monitoring/alerting configurations

Summary by CodeRabbit

  • 重构
    • 统一 RPC 追踪命名:将 grpc.method/grpc.options 替换为 rpc.system=grpc、rpc.method、rpc.options。
    • 更新跨度标识:操作名由 grpc.client 改为 rpc.client,来源由 auto.grpc 改为 auto.rpc。
    • 保持原有流程与头部注入逻辑不变;监控面板中的字段命名与筛选可能随之变化。

Updates the GrpcAspect to follow OpenTelemetry semantic conventions for RPC spans:
- Changes operation name from 'grpc.client' to 'rpc.client'
- Updates span origin from 'auto.grpc' to 'auto.rpc'
- Renames span data attributes: 'grpc.method' to 'rpc.method', 'grpc.options' to 'rpc.options'
- Adds 'rpc.system' attribute set to 'grpc' to identify the RPC system

This aligns the implementation with standard OpenTelemetry conventions for better compatibility and consistency with observability tools.
@coderabbitai
Copy link

coderabbitai bot commented Oct 12, 2025

Walkthrough

将 gRPC 追踪的标签与元数据从 grpc.* 统一迁移为 OpenTelemetry 风格的 rpc.*,并将 span 的 op 从 grpc.client 改为 rpc.client、origin 从 auto.grpc 改为 auto.rpc。逻辑与控制流保持不变,包括可追踪性判断与头部注入。

Changes

Cohort / File(s) Summary of changes
RPC 遥测键重命名与元数据调整
src/sentry/src/Tracing/Aspect/GrpcAspect.php
将数据负载键由 grpc.methodgrpc.options 改为 rpc.system=grpcrpc.methodrpc.options;将 span 元数据 setOp(grpc.client) 改为 setOp(rpc.client)setOrigin(auto.grpc) 改为 setOrigin(auto.rpc);其余控制流与头部注入逻辑不变。

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant App as 应用
    participant Aspect as GrpcAspect
    participant Tracer as Tracer/Span
    participant Client as gRPC 客户端

    App->>Aspect: 发起 gRPC 调用(request, options)
    Aspect->>Tracer: 创建/获取 span
    Note right of Tracer: setOp=rpc.client<br/>setOrigin=auto.rpc
    Aspect->>Tracer: 设定标签<br/>rpc.system=grpc<br/>rpc.method=method<br/>rpc.options=options
    Aspect->>Client: 注入追踪头后转发请求
    Client-->>Aspect: 返回响应/错误
    Aspect->>Tracer: 结束 span(记录结果)
    Aspect-->>App: 返回响应/错误
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

小兔敲键换新牌,grpc 化作 rpc 来。
标签整齐如队列,op 与 origin 同改。
代码仍循旧轨迹,埋点清晰更可爱。
啪嗒耳朵一甩,追踪之旅开怀。

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 该标题简洁明了地概述了变更的核心目的,即将 GrpcAspect 与 OpenTelemetry 语义规范对齐。标题具体且直接,没有使用模糊或多余的词汇。
✨ 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/grpc-semantic-conventions

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

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 requested a review from Copilot October 12, 2025 13:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR aligns the GrpcAspect with OpenTelemetry semantic conventions by updating span operation names, origins, and attributes to follow standard RPC naming patterns instead of gRPC-specific ones.

Key Changes

  • Updated span operation name from grpc.client to rpc.client
  • Changed span origin from auto.grpc to auto.rpc
  • Renamed span attributes to follow OTel conventions and added rpc.system attribute

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 f842f7f and b088b79.

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

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

Use the namespace pattern FriendsOfHyperf{ComponentName} in all component PHP source files

Files:

  • src/sentry/src/Tracing/Aspect/GrpcAspect.php
{src,tests}/**/*.php

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

Adhere to PSR-12 coding standards across PHP code

Files:

  • src/sentry/src/Tracing/Aspect/GrpcAspect.php
src/*/**

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

New components must follow the standard component structure under src/{component-name}/ including .gitattributes, .github, LICENSE, README.md, composer.json, and a src/ subdirectory

Files:

  • src/sentry/src/Tracing/Aspect/GrpcAspect.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). (12)
  • GitHub Check: Test on PHP 8.3 with Swoole 5.1.7
  • GitHub Check: Test on PHP 8.2 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.2 with Swoole 5.1.7
  • GitHub Check: Test on PHP 8.3 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.1 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.1 with Swoole 5.1.7
  • GitHub Check: Test on PHP 8.2 with Swoole 5.1.7
  • GitHub Check: Test on PHP 8.1 with Swoole 5.1.7
  • 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.3 with Swoole 6.0.2
  • GitHub Check: Test on PHP 8.3 with Swoole 5.1.7
🔇 Additional comments (3)
src/sentry/src/Tracing/Aspect/GrpcAspect.php (3)

70-70: Origin 更改与操作名保持一致。

将 origin 从 auto.grpc 改为 auto.rpc 与操作名的更改保持一致,符合 OpenTelemetry 命名约定。

同样需要注意这是破坏性变更:任何通过 origin 过滤的查询将受影响。


37-37: 验证功能标志命名的一致性。

此处仍使用 isTracingSpanEnabled('grpc') 检查功能是否启用,但 span 的操作名和属性已改为 rpc.*

请确认:

  1. 功能标志是否应保持为 'grpc'(因为这是专门针对 gRPC 追踪的功能)?
  2. 还是应该更改为 'rpc' 以与新的命名约定保持一致?

如果决定保持 'grpc',建议添加注释说明原因,以便未来维护者理解这一设计决策。


44-46: 属性名称更新符合 OpenTelemetry 语义,代码库中未发现 grpc.methodgrpc.options 的引用
请确认下游监控仪表板、告警和日志查询已切换至新的 rpc.* 属性名称。

@huangdijia huangdijia merged commit 455e0dc into main Oct 12, 2025
16 of 17 checks passed
@huangdijia huangdijia deleted the feat/grpc-semantic-conventions branch October 12, 2025 13:51
huangdijia added a commit that referenced this pull request Oct 12, 2025
#955)

Updates the GrpcAspect to follow OpenTelemetry semantic conventions for RPC spans:
- Changes operation name from 'grpc.client' to 'rpc.client'
- Updates span origin from 'auto.grpc' to 'auto.rpc'
- Renames span data attributes: 'grpc.method' to 'rpc.method', 'grpc.options' to 'rpc.options'
- Adds 'rpc.system' attribute set to 'grpc' to identify the RPC system

This aligns the implementation with standard OpenTelemetry conventions for better compatibility and consistency with observability tools.

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