Skip to content

Commit cb4311f

Browse files
cleptricstayallive
andauthored
Add support for the Queue Module (#902)
Co-authored-by: Alex Bouma <[email protected]>
1 parent 039fd4e commit cb4311f

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/Sentry/Laravel/Features/QueueIntegration.php

+17-8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class QueueIntegration extends Feature
3636

3737
private const QUEUE_PAYLOAD_BAGGAGE_DATA = 'sentry_baggage_data';
3838
private const QUEUE_PAYLOAD_TRACE_PARENT_DATA = 'sentry_trace_parent_data';
39+
private const QUEUE_PAYLOAD_PUBLISH_TIME = 'sentry_publish_time';
3940

4041
public function isApplicable(): bool
4142
{
@@ -78,6 +79,7 @@ public function onBoot(Dispatcher $events): void
7879
if ($payload !== null) {
7980
$payload[self::QUEUE_PAYLOAD_BAGGAGE_DATA] = getBaggage();
8081
$payload[self::QUEUE_PAYLOAD_TRACE_PARENT_DATA] = getTraceparent();
82+
$payload[self::QUEUE_PAYLOAD_PUBLISH_TIME] = microtime(true);
8183
}
8284

8385
return $payload;
@@ -103,9 +105,6 @@ public function handleJobQueueingEvent(JobQueueing $event): void
103105
}
104106

105107
$currentSpan
106-
->setData([
107-
'messaging.laravel.job' => $jobName,
108-
])
109108
->setDescription($jobName);
110109
}
111110

@@ -181,12 +180,22 @@ public function handleJobProcessingQueueEvent(JobProcessing $event): void
181180

182181
$resolvedJobName = $event->job->resolveName();
183182

183+
$receiveLatency = null;
184+
if ($event->job->payload()[self::QUEUE_PAYLOAD_PUBLISH_TIME] !== null) {
185+
$receiveLatency = microtime(true) - $event->job->payload()[self::QUEUE_PAYLOAD_PUBLISH_TIME];
186+
}
187+
184188
$job = [
185-
'job' => $event->job->getName(),
186-
'queue' => $event->job->getQueue(),
187-
'resolved' => $resolvedJobName,
188-
'attempts' => $event->job->attempts(),
189-
'connection' => $event->connectionName,
189+
'messaging.system' => 'laravel',
190+
191+
'messaging.destination.name' => $event->job->getQueue(),
192+
'messaging.destination.connection' => $event->connectionName,
193+
194+
'messaging.message.id' => (string) $event->job->getJobId(),
195+
'messaging.message.envelope.size' => strlen($event->job->getRawBody()),
196+
'messaging.message.body.size' => strlen(json_encode($event->job->payload()['data'])),
197+
'messaging.message.retry.count' => $event->job->attempts(),
198+
'messaging.message.receive.latency' => $receiveLatency,
190199
];
191200

192201
if ($context instanceof TransactionContext) {

0 commit comments

Comments
 (0)