-
-
Notifications
You must be signed in to change notification settings - Fork 27
refactor(sentry): standardize message ID generation using SentryUid in tracing aspects #943
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |||||
| use longlang\phpkafka\Protocol\RecordBatch\RecordHeader; | ||||||
| use Sentry\State\Scope; | ||||||
| use Sentry\Tracing\SpanContext; | ||||||
| use Sentry\Util\SentryUid; | ||||||
|
|
||||||
| use function FriendsOfHyperf\Sentry\trace; | ||||||
|
|
||||||
|
|
@@ -54,7 +55,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint) | |||||
|
|
||||||
| protected function sendAsync(ProceedingJoinPoint $proceedingJoinPoint) | ||||||
| { | ||||||
| $messageId = uniqid('kafka_', true); | ||||||
| $messageId = SentryUid::generate(); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major sendAsync:统一字符串化 message_id 避免类型/序列化差异,建议显式 (string)。 请修改为: - $messageId = SentryUid::generate();
+ $messageId = (string) SentryUid::generate();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| $destinationName = $proceedingJoinPoint->arguments['keys']['topic'] ?? 'unknown'; | ||||||
| $bodySize = strlen($proceedingJoinPoint->arguments['keys']['value'] ?? ''); | ||||||
|
|
||||||
|
|
@@ -107,7 +108,7 @@ function (Scope $scope) use ($proceedingJoinPoint, $messages) { | |||||
| $carrier = Carrier::fromSpan($span) | ||||||
| ->with([ | ||||||
| 'publish_time' => microtime(true), | ||||||
| 'message_id' => uniqid('kafka_', true), | ||||||
| 'message_id' => SentryUid::generate(), | ||||||
| 'destination_name' => $this->getTopic(), | ||||||
| 'body_size' => strlen((string) $this->getValue()), | ||||||
| ]); | ||||||
|
|
||||||
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.
🛠️ Refactor suggestion | 🟠 Major
AMQP:显式字符串化 message_id
为避免 headers/Span data 中的类型不一致与潜在序列化问题,建议强转为 string。
请修改为:
📝 Committable suggestion
🤖 Prompt for AI Agents