-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
Queue integration fixes #904
Changes from 3 commits
7b4a287
9cb1b47
c1d3a47
211f6da
45e7a23
cc9d2e0
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 |
---|---|---|
|
@@ -68,6 +68,7 @@ public function onBoot(Dispatcher $events): void | |
->setOp(self::QUEUE_SPAN_OP_QUEUE_PUBLISH) | ||
->setData([ | ||
'messaging.system' => 'laravel', | ||
'messaging.message.id' => $payload['uuid'] ?? null, | ||
'messaging.destination.name' => $queue, | ||
'messaging.destination.connection' => $connection, | ||
]) | ||
|
@@ -164,9 +165,11 @@ public function handleJobProcessingQueueEvent(JobProcessing $event): void | |
return; | ||
} | ||
|
||
$jobPayload = $event->job->payload(); | ||
|
||
if ($parentSpan === null) { | ||
$baggage = $event->job->payload()[self::QUEUE_PAYLOAD_BAGGAGE_DATA] ?? null; | ||
$traceParent = $event->job->payload()[self::QUEUE_PAYLOAD_TRACE_PARENT_DATA] ?? null; | ||
$baggage = $jobPayload[self::QUEUE_PAYLOAD_BAGGAGE_DATA] ?? null; | ||
$traceParent = $jobPayload[self::QUEUE_PAYLOAD_TRACE_PARENT_DATA] ?? null; | ||
|
||
$context = continueTrace($traceParent ?? '', $baggage ?? ''); | ||
|
||
|
@@ -180,22 +183,19 @@ public function handleJobProcessingQueueEvent(JobProcessing $event): void | |
|
||
$resolvedJobName = $event->job->resolveName(); | ||
|
||
$receiveLatency = null; | ||
if ($event->job->payload()[self::QUEUE_PAYLOAD_PUBLISH_TIME] !== null) { | ||
$receiveLatency = microtime(true) - $event->job->payload()[self::QUEUE_PAYLOAD_PUBLISH_TIME]; | ||
} | ||
$jobPublishedAt = $jobPayload[self::QUEUE_PAYLOAD_PUBLISH_TIME] ?? null; | ||
|
||
$job = [ | ||
'messaging.system' => 'laravel', | ||
|
||
'messaging.destination.name' => $event->job->getQueue(), | ||
'messaging.destination.connection' => $event->connectionName, | ||
'messaging.message.id' => (string) $event->job->getJobId(), | ||
|
||
'messaging.message.id' => $jobPayload['uuid'] ?? $event->job->getJobId(), | ||
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. We need to keep the string cast for 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. It's documented as returning a string? When doesn't it do that? Maybe we should just rely on |
||
'messaging.message.envelope.size' => strlen($event->job->getRawBody()), | ||
'messaging.message.body.size' => strlen(json_encode($event->job->payload()['data'])), | ||
'messaging.message.body.size' => strlen(json_encode($jobPayload['data'] ?? [])), | ||
'messaging.message.retry.count' => $event->job->attempts(), | ||
'messaging.message.receive.latency' => $receiveLatency, | ||
'messaging.message.receive.latency' => $jobPublishedAt !== null ? microtime(true) - $jobPublishedAt : null, | ||
]; | ||
|
||
if ($context instanceof TransactionContext) { | ||
|
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.
This is prepended with "queue:" to something like:
queues:queue-name
We need to "fix" this because otherwise the published are on the wrong destination.
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.
Turns out... only the Redis driver does this. We could argue Laravel should fix this but let's also fix it ourselfs 😄