-
-
Notifications
You must be signed in to change notification settings - Fork 27
feat(sentry): align GrpcAspect with OpenTelemetry semantic conventions #955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Walkthrough将 gRPC 追踪的标签与元数据从 grpc.* 统一迁移为 OpenTelemetry 风格的 rpc.*,并将 span 的 op 从 grpc.client 改为 rpc.client、origin 从 auto.grpc 改为 auto.rpc。逻辑与控制流保持不变,包括可追踪性判断与头部注入。 Changes
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: 返回响应/错误
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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.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. Comment |
There was a problem hiding this 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.clienttorpc.client - Changed span origin from
auto.grpctoauto.rpc - Renamed span attributes to follow OTel conventions and added
rpc.systemattribute
There was a problem hiding this 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
📒 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.*。请确认:
- 功能标志是否应保持为
'grpc'(因为这是专门针对 gRPC 追踪的功能)?- 还是应该更改为
'rpc'以与新的命名约定保持一致?如果决定保持
'grpc',建议添加注释说明原因,以便未来维护者理解这一设计决策。
44-46: 属性名称更新符合 OpenTelemetry 语义,代码库中未发现grpc.method或grpc.options的引用
请确认下游监控仪表板、告警和日志查询已切换至新的rpc.*属性名称。
#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>
Summary
This PR updates the
GrpcAspectto align with OpenTelemetry semantic conventions for RPC spans:grpc.clienttorpc.clientauto.grpctoauto.rpcgrpc.method→rpc.methodgrpc.options→rpc.optionsrpc.systemattribute set togrpcThese changes improve compatibility with OpenTelemetry standards and observability tools that expect standard RPC span naming conventions.
Test plan
rpc.systemattribute is set togrpcrpc.clientin tracesSummary by CodeRabbit