From 872cbeb059b0418a363c8b3d7efc2c186bc4a362 Mon Sep 17 00:00:00 2001 From: Milan Zivanovic Date: Fri, 4 Oct 2019 16:41:10 +0200 Subject: [PATCH] body property added for sent and consumed message stats --- ClientMonitoringExtension.php | 3 ++- ConsumedMessageStats.php | 12 ++++++++++++ ConsumerMonitoringExtension.php | 2 ++ SentMessageStats.php | 14 +++++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/ClientMonitoringExtension.php b/ClientMonitoringExtension.php index 11e7054..666acf8 100644 --- a/ClientMonitoringExtension.php +++ b/ClientMonitoringExtension.php @@ -43,7 +43,8 @@ public function onPostSend(PostSend $context): void $context->getTransportMessage()->getMessageId(), $context->getTransportMessage()->getCorrelationId(), $context->getTransportMessage()->getHeaders(), - $context->getTransportMessage()->getProperties() + $context->getTransportMessage()->getProperties(), + $context->getTransportMessage()->getBody() ); $this->safeCall(function () use ($stats) { diff --git a/ConsumedMessageStats.php b/ConsumedMessageStats.php index 928bce0..744f1db 100644 --- a/ConsumedMessageStats.php +++ b/ConsumedMessageStats.php @@ -51,6 +51,11 @@ class ConsumedMessageStats implements Stats */ protected $properties; + /** + * @var string + */ + protected $body; + /** * @var bool; */ @@ -100,6 +105,7 @@ public function __construct( ?string $correlationId, array $headers, array $properties, + string $body, bool $redelivered, string $status, string $errorClass = null, @@ -117,6 +123,7 @@ public function __construct( $this->correlationId = $correlationId; $this->headers = $headers; $this->properties = $properties; + $this->body = $body; $this->redelivered = $redelivered; $this->status = $status; @@ -168,6 +175,11 @@ public function getProperties(): array return $this->properties; } + public function getBody(): string + { + return $this->body; + } + public function isRedelivered(): bool { return $this->redelivered; diff --git a/ConsumerMonitoringExtension.php b/ConsumerMonitoringExtension.php index af5ce98..890e448 100644 --- a/ConsumerMonitoringExtension.php +++ b/ConsumerMonitoringExtension.php @@ -174,6 +174,7 @@ public function onProcessorException(ProcessorException $context): void $context->getMessage()->getCorrelationId(), $context->getMessage()->getHeaders(), $context->getMessage()->getProperties(), + $context->getMessage()->getBody(), $context->getMessage()->isRedelivered(), ConsumedMessageStats::STATUS_FAILED, get_class($context->getException()), @@ -256,6 +257,7 @@ public function onResult(MessageResult $context): void $context->getMessage()->getCorrelationId(), $context->getMessage()->getHeaders(), $context->getMessage()->getProperties(), + $context->getMessage()->getBody(), $context->getMessage()->isRedelivered(), $status ); diff --git a/SentMessageStats.php b/SentMessageStats.php index 6106d3d..1b5e590 100644 --- a/SentMessageStats.php +++ b/SentMessageStats.php @@ -41,6 +41,11 @@ class SentMessageStats implements Stats */ protected $properties; + /** + * @var string + */ + protected $body; + public function __construct( int $timestampMs, string $destination, @@ -48,7 +53,8 @@ public function __construct( ?string $messageId, ?string $correlationId, array $headers, - array $properties + array $properties, + string $body ) { $this->timestampMs = $timestampMs; $this->destination = $destination; @@ -57,6 +63,7 @@ public function __construct( $this->correlationId = $correlationId; $this->headers = $headers; $this->properties = $properties; + $this->body = $body; } public function getTimestampMs(): int @@ -93,4 +100,9 @@ public function getProperties(): array { return $this->properties; } + + public function getBody(): string + { + return $this->body; + } }