-
-
Notifications
You must be signed in to change notification settings - Fork 27
feat: add server address and HTTP method tracing for Elasticsearch operations #1022
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
…erations This enhancement adds comprehensive server connection metadata to Elasticsearch spans, including server address, port, HTTP method, and full URL. It supports both legacy Elasticsearch\Client and modern Elastic\Elasticsearch\Client implementations. Changes: - Extract server address, port, and request method from Elasticsearch clients - Add support for both Elasticsearch client versions - Use tap() helper for cleaner result processing with side effects - Gracefully handle errors when extracting connection metadata - Remove TODO comments as the functionality is now implemented
Walkthrough将 Elasticsearch 追踪切面主流程用 Changes
Sequence Diagram(s)sequenceDiagram
participant JP as JoinPoint
participant Aspect as ElasticsearchAspect
participant Client as Elasticsearch Client
participant Transport as Transport
participant Span as Tracing Span
JP->>Aspect: 执行切面逻辑
Aspect->>JP: 调用 proceedingJoinPoint.process()
JP->>Client: 运行 Elasticsearch 操作
Client->>Transport: 读取传输状态 / 最后请求
Client-->>JP: 返回结果
JP-->>Aspect: 结果回传(通过 tap 保留返回值)
rect rgb(220, 235, 255)
Note over Aspect,Span: 防御性元数据提取(v7 / v8)
Aspect->>Span: 记录 elasticsearch.result
Aspect->>Transport: 读取 server.address / server.port / request method / url
Aspect->>Span: 设置 server.address、server.port、http.request.method、url.full
end
Aspect-->>JP: 返回原始结果
估计代码审查工作量🎯 4 (复杂) | ⏱️ ~45 分钟 需重点检查:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🧰 Additional context used🧬 Code graph analysis (1)src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php (3)
🔇 Additional comments (1)
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.32)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.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php (4)
src/sentry/src/Tracing/Tracer.php (1)
trace(70-93)src/sentry/src/Function.php (2)
trace(48-53)feature(24-27)src/sentry/src/Tracing/Aspect/RedisAspect.php (1)
process(47-94)src/sentry/src/Feature.php (1)
isTracingTagEnabled(48-51)
🪛 GitHub Check: Test on PHP 8.1 with Swoole 6.0.2
src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php
[failure] 79-79:
Call to an undefined method Elastic\Transport\Transport::getLastConnection().
[failure] 79-79:
Access to property $transport on an unknown class Elasticsearch\Client.
[failure] 78-78:
Match arm comparison between class-string&literal-string and 'Elasticsearch\Client' is always false.
[failure] 77-77:
Access to constant class on an unknown class Elasticsearch\Client.
[failure] 76-76:
PHPDoc tag @var for variable $client contains unknown class Elasticsearch\Client.
🪛 GitHub Check: Test on PHP 8.2 with Swoole 6.0.2
src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php
[failure] 79-79:
Call to an undefined method Elastic\Transport\Transport::getLastConnection().
[failure] 79-79:
Access to property $transport on an unknown class Elasticsearch\Client.
[failure] 78-78:
Match arm comparison between class-string&literal-string and 'Elasticsearch\Client' is always false.
[failure] 77-77:
Access to constant class on an unknown class Elasticsearch\Client.
[failure] 76-76:
PHPDoc tag @var for variable $client contains unknown class Elasticsearch\Client.
⏰ 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). (16)
- GitHub Check: Test on PHP 8.1 with Swoole 5.1.8
- GitHub Check: Test on PHP 8.1 with Swoole 6.1.2
- GitHub Check: Test on PHP 8.2 with Swoole 6.1.2
- GitHub Check: Test on PHP 8.1 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.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 6.1.2
- GitHub Check: Test on PHP 8.1 with Swoole 5.1.8
- GitHub Check: Test on PHP 8.2 with Swoole 5.1.8
- GitHub Check: Test on PHP 8.1 with Swoole 6.1.2
- 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.2 with Swoole 6.1.2
- GitHub Check: Test on PHP 8.3 with Swoole 6.1.2
🔇 Additional comments (1)
src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php (1)
65-72: 使用tap包裹process()并按特性开关记录elasticsearch.result的做法很合理这里沿用了
RedisAspect中相同的模式,通过tap($proceedingJoinPoint->process(), ...)在不改变返回值的前提下给 span 附加数据,并且只有在elasticsearch.resulttracing tag 开启时才编码结果写入,开销可控,结构也与现有 Redis 实现保持一致。
…to separate methods
Summary
Elasticsearch\Clientand modernElastic\Elasticsearch\Clientimplementationstap()helper for cleaner result processing with side effectsTest plan
Summary by CodeRabbit
Bug 修复
功能改进
✏️ Tip: You can customize this high-level summary in your review settings.