Skip to content

Commit b530369

Browse files
authored
feat(sentry): add producer identification to AMQP tracing (#966)
Add producer application name to AMQP message tracing data to enable better observability and message flow tracking across services. This enhancement allows identifying which service produced a message in distributed tracing scenarios. Changes: - Add 'producer' attribute to AMQP producer span data using app_name config - Capture producer information in consumer spans via message carrier - Use 'unknown' as fallback when producer information is unavailable Co-authored-by: Deeka Wong <[email protected]>
1 parent 2e1e3d2 commit b530369

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/Tracing/Aspect/AmqpProducerAspect.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Sentry\Util\SentryUid;
2626

2727
use function FriendsOfHyperf\Sentry\trace;
28+
use function Hyperf\Config\config;
2829

2930
/**
3031
* @property array{application_headers?:AMQPTable} $properties
@@ -86,6 +87,7 @@ function (Scope $scope) use ($proceedingJoinPoint, $producerMessage, $messageId,
8687
'message_id' => $messageId,
8788
'destination_name' => $destinationName,
8889
'body_size' => $bodySize,
90+
'producer' => config('app_name', 'unknown'),
8991
]);
9092
(function () use ($carrier) {
9193
$this->properties['application_headers'] ??= new AMQPTable();

src/Tracing/Listener/EventHandleListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ protected function handleAmqpMessageProcessing(AmqpEvent\BeforeConsume $event):
586586
'messaging.message.body.size' => $carrier?->get('body_size'),
587587
'messaging.message.receive.latency' => $carrier?->has('publish_time') ? (microtime(true) - $carrier->get('publish_time')) : null,
588588
'messaging.message.retry.count' => 0,
589+
'messaging.message.producer' => $carrier?->get('producer', 'unknown'),
589590
'messaging.destination.name' => $carrier?->get('destination_name') ?: implode(', ', (array) $message->getRoutingKey()),
590591
'messaging.amqp.message.type' => $message->getTypeString(),
591592
'messaging.amqp.message.routing_key' => $message->getRoutingKey(),

0 commit comments

Comments
 (0)